Medical Imaging Interaction Toolkit  2016.11.0
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_AS_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_AS_ERRORS # treat all 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_AS_ERRORS)
54  list(APPEND _EXEC_OPTIONS WARNINGS_AS_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(MODULE_IS_ENABLED)
77  # Add meta dependencies (e.g. on auto-load modules from depending modules)
78  if(TARGET ${CMAKE_PROJECT_NAME}-autoload)
79  add_dependencies(${MODULE_TARGET} ${CMAKE_PROJECT_NAME}-autoload)
80  endif()
81 
82  # Create batch and VS user files for Windows platforms
84  if(WIN32)
85  set(_batch_file_in "${CMAKE_CURRENT_SOURCE_DIR}/${MODULE_TARGET}.bat.in")
86  if(NOT EXISTS "${_batch_file_in}")
87  set(_batch_file_in "${MITK_CMAKE_DIR}/StartApp.bat.in")
88  endif()
89  if(CMAKE_RUNTIME_OUTPUT_DIRECTORY)
90  set(_batch_file_out_dir "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
91  else()
92  set(_batch_file_out_dir "${CMAKE_CURRENT_BINARY_DIR}")
93  endif()
94  if(NOT EXEC_NO_BATCH_FILE)
95  foreach(BUILD_TYPE debug release)
96  mitkFunctionCreateWindowsBatchScript(
97  ${_batch_file_in} ${_batch_file_out_dir}/${MODULE_TARGET}_${BUILD_TYPE}.bat
98  ${BUILD_TYPE}
99  )
100  endforeach()
101  endif()
102  mitkFunctionConfigureVisualStudioUserProjectFile(
103  NAME ${MODULE_TARGET}
104  )
105  endif()
106  endif()
107 
108 endmacro()
mitk_create_module()
mitkFunctionCreateWindowsBatchScript(in, out, build_type)
static void info(const char *fmt,...)
Definition: svm.cpp:100
mitk_create_executable()
const std::string TARGET