Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkMacroCreateExecutable.cmake
Go to the documentation of this file.
1 ##################################################################
2 #
3 # MITK_CREATE_EXECUTABLE
4 #
5 #! Creates an executable with MITK dependencies and batch files
6 #! for proper application start-up.
7 #!
8 #! USAGE:
9 #!
10 #! \code
11 #! MITK_CREATE_EXECUTABLE( [<exectuableName>]
12 #! [DEPENDS <modules we need>]
13 #! [PACKAGE_DEPENDS <packages we need, like ITK, VTK, QT>]
14 #! [INCLUDE_DIRS <list of additional include directories>]
15 #! [TARGET_DEPENDS <list of additional dependencies>
16 #! [WARNINGS_NO_ERRORS]
17 #! \endcode
18 #!
19 #! \param EXECUTABLE_NAME The name for the new executable target
20 ##################################################################
22 
23  set(_macro_params
24  VERSION # version number, e.g. "1.2.0"
25  FILES_CMAKE # file name of a CMake file setting source list variables
26  # (defaults to files.cmake)
27  DESCRIPTION # a description for the executable
28  )
29 
30  set(_macro_multiparams
31  SUBPROJECTS # list of CDash labels
32  INCLUDE_DIRS # additional include dirs
33  DEPENDS # list of modules this module depends on
34  PACKAGE_DEPENDS # list of "packages" this module depends on (e.g. Qt, VTK, etc.)
35  TARGET_DEPENDS # list of CMake targets this executable should depend on
36  ADDITIONAL_LIBS # list of additional libraries linked to this executable
37  CPP_FILES # (optional) list of cpp files
38  )
39 
40  set(_macro_options
41  NO_INIT # do not create CppMicroServices initialization code
42  NO_FEATURE_INFO # do not create a feature info by calling add_feature_info()
43  NO_BATCH_FILE # do not create batch files on Windows
44  WARNINGS_NO_ERRORS # do not treat compiler warnings as errors
45  )
46 
47  cmake_parse_arguments(EXEC "${_macro_options}" "${_macro_params}" "${_macro_multiparams}" ${ARGN})
48 
49  set(_EXEC_OPTIONS EXECUTABLE)
50  if(EXEC_NO_INIT)
51  list(APPEND _EXEC_OPTIONS NO_INIT)
52  endif()
53  if(EXEC_WARNINGS_NO_ERRORS)
54  list(APPEND _EXEC_OPTIONS WARNINGS_NO_ERRORS)
55  endif()
56  if(EXEC_NO_FEATURE_INFO)
57  list(APPEND _EXEC_OPTIONS NO_FEATURE_INFO)
58  endif()
59 
60  mitk_create_module(${EXEC_UNPARSED_ARGUMENTS}
61  SUBPROJECTS ${EXEC_SUBPROJECTS}
62  VERSION ${EXEC_VERSION}
63  INCLUDE_DIRS ${EXEC_INCLUDE_DIRS}
64  DEPENDS ${EXEC_DEPENDS}
65  PACKAGE_DEPENDS ${EXEC_PACKAGE_DEPENDS}
66  TARGET_DEPENDS ${EXEC_TARGET_DEPENDS}
67  ADDITIONAL_LIBS ${EXEC_ADDITIONAL_LIBS}
68  FILES_CMAKE ${EXEC_FILES_CMAKE}
69  CPP_FILES ${EXEC_CPP_FILES}
70  DESCRIPTION "${DESCRIPTION}"
71  ${_EXEC_OPTIONS}
72  )
73 
74  set(EXECUTABLE_IS_ENABLED ${MODULE_IS_ENABLED})
75  set(EXECUTABLE_TARGET ${MODULE_TARGET})
76  if(EXECUTABLE_IS_ENABLED)
77  set_property(GLOBAL APPEND PROPERTY MITK_EXECUTABLE_TARGETS ${EXECUTABLE_TARGET})
78  # Add meta dependencies (e.g. on auto-load modules from depending modules)
79  if(TARGET ${CMAKE_PROJECT_NAME}-autoload)
80  add_dependencies(${MODULE_TARGET} ${CMAKE_PROJECT_NAME}-autoload)
81  endif()
82 
83  # Create batch and VS user files for Windows platforms
85  if(WIN32)
86  set(_batch_file_in "${CMAKE_CURRENT_SOURCE_DIR}/${MODULE_TARGET}.bat.in")
87  if(NOT EXISTS "${_batch_file_in}")
88  set(_batch_file_in "${MITK_CMAKE_DIR}/StartApp.bat.in")
89  endif()
90  if(CMAKE_RUNTIME_OUTPUT_DIRECTORY)
91  set(_batch_file_out_dir "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
92  else()
93  set(_batch_file_out_dir "${CMAKE_CURRENT_BINARY_DIR}")
94  endif()
95  if(NOT EXEC_NO_BATCH_FILE)
96  if(NOT EXEC_NAME)
97  set(EXEC_NAME ${MODULE_TARGET})
98  endif()
99  foreach(BUILD_TYPE debug release)
101  ${_batch_file_in} ${_batch_file_out_dir}/${MODULE_TARGET}_${BUILD_TYPE}.bat
102  ${BUILD_TYPE}
103  )
104  endforeach()
105  endif()
107  NAME ${MODULE_TARGET}
108  )
109  endif()
110  endif()
111 
112 endmacro()
mitk_create_module()
mitkFunctionCreateWindowsBatchScript(in, out, build_type)
static void info(const char *fmt,...)
Definition: svm.cpp:86
mitkFunctionConfigureVisualStudioUserProjectFile()
This function will configure a user file for visual studio projects.
const std::string NAME
mitk_create_executable()
const std::string TARGET