Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkFunctionCreateCommandLineApp.cmake
Go to the documentation of this file.
1 #!
2 #! Create a Command Line App.
3 #!
4 #! \brief This function will create a command line executable and the scripts required to run it
5 #!
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
10 #!
11 #! Assuming that there exists a file called <code>MyApp.cpp</code>, an example call looks like:
12 #! \code
13 #! mitkFunctionCreateCommandLineApp(
14 #! NAME MyApp
15 #! DEPENDS MitkCore MitkPlanarFigure
16 #! PACKAGE_DEPENDS ITK VTK
17 #! )
18 #! \endcode
19 #!
20 
22 
23  set(_function_params
24  NAME # Name of the command line app
25  )
26 
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
31  )
32 
33  set(_function_options
34 
35  )
36 
37  cmake_parse_arguments(CMDAPP "${_function_options}" "${_function_params}" "${_function_multiparams}" ${ARGN})
38 
39  if(NOT CMDAPP_NAME)
40  message(FATAL_ERROR "NAME argument cannot be empty.")
41  endif()
42 
43  if(NOT CMDAPP_CPP_FILES)
44  set(CMDAPP_CPP_FILES ${CMDAPP_NAME}.cpp)
45  endif()
46 
47  mitk_create_executable(${CMDAPP_NAME}
48  DEPENDS MitkCommandLine ${CMDAPP_DEPENDS}
49  PACKAGE_DEPENDS ${CMDAPP_PACKAGE_DEPENDS}
50  CPP_FILES ${CMDAPP_CPP_FILES}
51  )
52 
53  if(EXECUTABLE_IS_ENABLED)
54 
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)
58  endif()
59 
60  get_target_property(_is_bundle ${EXECUTABLE_TARGET} MACOSX_BUNDLE)
61 
62  if(APPLE)
63  if(_is_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 . )
70  else()
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)
76  else()
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) ")
83 
84  install(TARGETS ${EXECUTABLE_TARGET} RUNTIME DESTINATION ${bundle_name}.app/Contents/MacOS/)
85  endforeach()
86  endif()
87  endif()
88  else()
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)
93  endif()
94  endif()
95 endfunction()
static char * line
Definition: svm.cpp:2884
mitkFunctionCreateCommandLineApp()
This function will create a command line executable and the scripts required to run it...
const std::string NAME