2 #! Create a Command Line App.
4 #! \brief This function will create a command line executable and the scripts required to run it
6 #! \param NAME (required) Name of the command line app
7 #! \param DEPENDS (optional) Required MITK modules beyond MitkCommandLine
8 #! \param PACKAGE_DEPENDS (optional) list of "packages" this command line app depends on (e.g. ITK, VTK, etc.)
9 #! \param CPP_FILES (optional) list of cpp files, if it is not given NAME.cpp is assumed
11 #! Assuming that there exists a file called <code>MyApp.cpp</code>, an example call looks like:
13 #! mitkFunctionCreateCommandLineApp(
15 #! DEPENDS MitkCore MitkPlanarFigure
16 #! PACKAGE_DEPENDS ITK VTK
27 set(_function_multiparams
28 DEPENDS # list of modules
this command
line app depends on
29 PACKAGE_DEPENDS # list of
"packages" this command
line app depends on (e.g. ITK, VTK, etc.)
30 CPP_FILES # (optional) list of cpp files,
if it is not given
NAME.cpp is assumed
37 cmake_parse_arguments(CMDAPP "${_function_options}
" "${_function_params}
" "${_function_multiparams}
" ${ARGN})
40 message(FATAL_ERROR "NAME argument cannot be empty.
")
43 if(NOT CMDAPP_CPP_FILES)
44 set(CMDAPP_CPP_FILES ${CMDAPP_NAME}.cpp)
47 mitk_create_executable(${CMDAPP_NAME}
48 DEPENDS MitkCommandLine ${CMDAPP_DEPENDS}
49 PACKAGE_DEPENDS ${CMDAPP_PACKAGE_DEPENDS}
50 CPP_FILES ${CMDAPP_CPP_FILES}
53 if(EXECUTABLE_IS_ENABLED)
55 # On Linux, create a shell script to start a relocatable application
56 if(UNIX AND NOT APPLE)
57 install(PROGRAMS "${MITK_SOURCE_DIR}/
CMake/RunInstalledApp.sh
" DESTINATION ".
" RENAME ${EXECUTABLE_TARGET}.sh)
60 get_target_property(_is_bundle ${EXECUTABLE_TARGET} MACOSX_BUNDLE)
64 set(_target_locations ${EXECUTABLE_TARGET}.app)
65 set(${_target_locations}_qt_plugins_install_dir ${EXECUTABLE_TARGET}.app/Contents/MacOS)
66 set(_bundle_dest_dir ${EXECUTABLE_TARGET}.app/Contents/MacOS)
67 set(_qt_plugins_for_current_bundle ${EXECUTABLE_TARGET}.app/Contents/MacOS)
68 set(_qt_conf_install_dirs ${EXECUTABLE_TARGET}.app/Contents/Resources)
69 install(TARGETS ${EXECUTABLE_TARGET} BUNDLE DESTINATION . )
71 if(NOT MACOSX_BUNDLE_NAMES)
72 set(_qt_conf_install_dirs bin)
73 set(_target_locations bin/${EXECUTABLE_TARGET})
74 set(${_target_locations}_qt_plugins_install_dir bin)
75 install(TARGETS ${EXECUTABLE_TARGET} RUNTIME DESTINATION bin)
77 foreach(bundle_name ${MACOSX_BUNDLE_NAMES})
78 list(APPEND _qt_conf_install_dirs ${bundle_name}.app/Contents/Resources)
79 set(_current_target_location ${bundle_name}.app/Contents/MacOS/${EXECUTABLE_TARGET})
80 list(APPEND _target_locations ${_current_target_location})
81 set(${_current_target_location}_qt_plugins_install_dir ${bundle_name}.app/Contents/MacOS)
82 message( " set(${_current_target_location}_qt_plugins_install_dir ${bundle_name}.app/Contents/MacOS)
")
84 install(TARGETS ${EXECUTABLE_TARGET} RUNTIME DESTINATION ${bundle_name}.app/Contents/MacOS/)
89 set(_target_locations bin/${EXECUTABLE_TARGET}${CMAKE_EXECUTABLE_SUFFIX})
90 set(${_target_locations}_qt_plugins_install_dir bin)
91 set(_qt_conf_install_dirs bin)
92 install(TARGETS ${EXECUTABLE_TARGET} RUNTIME DESTINATION bin)
mitkFunctionCreateCommandLineApp()
This function will create a command line executable and the scripts required to run it...