2 #! Create a BlueBerry application.
4 #! \brief This function will create a BlueBerry application together with all
5 #! necessary provisioning and configuration data and install support.
7 #! \param NAME (required) The name of the executable.
8 #! \param DESCRIPTION (optional) A human-readable description of your application.
9 #! The usage depends on the CPack generator (on Windows, this is a descriptive
10 #! text for the created shortcuts).
11 #! \param SOURCES (optional) A list of source files to compile into your executable. Defaults
13 #! \param PLUGINS (optional) A list of required plug-ins. Defaults to all known plug-ins.
14 #! \param EXCLUDE_PLUGINS (optional) A list of plug-ins which should not be used. Mainly
15 #! useful if PLUGINS was not used.
16 #! \param LINK_LIBRARIES A list of libraries to be linked with the executable.
17 #! \param LIBRARY_DIRS A list of directories to pass through to MITK_INSTALL_TARGETS
18 #! \param SHOW_CONSOLE (option) Show the console output window (on Windows).
19 #! \param NO_PROVISIONING (option) Do not create provisioning files.
20 #! \param NO_INSTALL (option) Do not install this executable
22 #! Assuming that there exists a file called <code>MyApp.cpp</code>, an example call looks like:
24 #! mitkFunctionCreateBlueBerryApplication(
26 #! DESCRIPTION "MyApp - New ways to explore medical data"
27 #! EXCLUDE_PLUGINS org.mitk.gui.qt.extapplication
34 cmake_parse_arguments(_APP
"SHOW_CONSOLE;NO_PROVISIONING;NO_INSTALL" "NAME;DESCRIPTION" "SOURCES;PLUGINS;EXCLUDE_PLUGINS;LINK_LIBRARIES;LIBRARY_DIRS" ${ARGN})
37 message(FATAL_ERROR
"NAME argument cannot be empty.")
41 set(_APP_SOURCES ${_APP_NAME}.cpp)
45 ctkFunctionGetAllPluginTargets(_APP_PLUGINS)
47 set(_plugins ${_APP_PLUGINS})
49 foreach(_plugin ${_plugins})
50 string(REPLACE
"." "_" _plugin_target ${_plugin})
51 list(APPEND _APP_PLUGINS ${_plugin_target})
54 # get all plug-in dependencies
55 ctkFunctionGetPluginDependencies(_plugin_deps PLUGINS ${_APP_PLUGINS}
ALL)
56 # add the dependencies to the list of application plug-ins
57 list(APPEND _APP_PLUGINS ${_plugin_deps})
60 # -----------------------------------------------------------------------
61 # Set up include and link dirs for the executable
62 # -----------------------------------------------------------------------
65 ${org_blueberry_core_runtime_INCLUDE_DIRS}
68 # -----------------------------------------------------------------------
69 # Add executable icon (Windows)
70 # -----------------------------------------------------------------------
71 set(WINDOWS_ICON_RESOURCE_FILE
"")
73 if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/icons/${_APP_NAME}.rc
")
74 set(WINDOWS_ICON_RESOURCE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/icons/${_APP_NAME}.rc
")
78 # -----------------------------------------------------------------------
79 # Create the executable and link libraries
80 # -----------------------------------------------------------------------
82 set(_app_compile_flags )
84 set(_app_compile_flags "${_app_compile_flags} -DPOCO_NO_UNWINDOWS -DWIN32_LEAN_AND_MEAN
")
88 add_executable(${_APP_NAME} MACOSX_BUNDLE ${_APP_SOURCES} ${WINDOWS_ICON_RESOURCE_FILE})
90 add_executable(${_APP_NAME} MACOSX_BUNDLE WIN32 ${_APP_SOURCES} ${WINDOWS_ICON_RESOURCE_FILE})
92 mitk_use_modules(TARGET ${_APP_NAME} MODULES mbilog PACKAGES Poco Qt5|Core)
94 set_target_properties(${_APP_NAME} PROPERTIES
95 COMPILE_FLAGS "${_app_compile_flags}
")
97 target_link_libraries(${_APP_NAME} PRIVATE org_blueberry_core_runtime ${_APP_LINK_LIBRARIES})
99 target_link_libraries(${_APP_NAME} PRIVATE ${QT_QTMAIN_LIBRARY})
102 # -----------------------------------------------------------------------
103 # Add executable icon and bundle name (Mac)
104 # -----------------------------------------------------------------------
106 if( _APP_DESCRIPTION)
107 set_target_properties(${_APP_NAME} PROPERTIES MACOSX_BUNDLE_NAME "${_APP_DESCRIPTION}
")
109 set_target_properties(${_APP_NAME} PROPERTIES MACOSX_BUNDLE_NAME "${_APP_NAME}
")
111 set(icon_name "icon.icns
")
112 set(icon_full_path "${CMAKE_CURRENT_SOURCE_DIR}/icons/${icon_name}
")
113 if(EXISTS "${icon_full_path}
")
114 set_target_properties(${_APP_NAME} PROPERTIES MACOSX_BUNDLE_ICON_FILE "${icon_name}
")
115 file(COPY ${icon_full_path} DESTINATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${_APP_NAME}.app/Contents/Resources/
")
116 INSTALL (FILES ${icon_full_path} DESTINATION "${_APP_NAME}.app/Contents/Resources/
")
120 # -----------------------------------------------------------------------
121 # Set build time dependencies
122 # -----------------------------------------------------------------------
124 # This ensures that all enabled plug-ins are up-to-date when the
125 # executable is build.
127 ctkMacroGetAllProjectTargetLibraries("${_APP_PLUGINS}
" _project_plugins)
128 if(_APP_EXCLUDE_PLUGINS AND _project_plugins)
129 set(_exclude_targets)
130 foreach(_exclude_plugin ${_APP_EXCLUDE_PLUGINS})
131 string(REPLACE ".
" "_
" _exclude_target ${_exclude_plugin})
132 list(APPEND _exclude_targets ${_exclude_target})
134 list(REMOVE_ITEM _project_plugins ${_exclude_targets})
137 add_dependencies(${_APP_NAME} ${_project_plugins})
141 # -----------------------------------------------------------------------
142 # Additional files needed for the executable
143 # -----------------------------------------------------------------------
145 if(NOT _APP_NO_PROVISIONING)
147 # Create a provisioning file, listing all plug-ins
148 set(_prov_file "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${_APP_NAME}.provisioning
")
149 mitkFunctionCreateProvisioningFile(FILE ${_prov_file}
150 PLUGINS ${_APP_PLUGINS}
151 EXCLUDE_PLUGINS ${_APP_EXCLUDE_PLUGINS}
156 # Create a .ini file for initial parameters
157 if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${_APP_NAME}.ini
")
158 configure_file(${_APP_NAME}.ini
159 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${_APP_NAME}.ini)
162 # Create batch and VS user files for Windows platforms
163 include(mitkFunctionCreateWindowsBatchScript)
166 set(template_name "start${_APP_NAME}.bat.in
")
167 if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${template_name}
")
168 foreach(BUILD_TYPE debug release)
169 mitkFunctionCreateWindowsBatchScript(${template_name}
170 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/start${_APP_NAME}_${BUILD_TYPE}.bat
174 mitkFunctionConfigureVisualStudioUserProjectFile(
179 # -----------------------------------------------------------------------
181 # -----------------------------------------------------------------------
183 if(NOT _APP_NO_INSTALL)
185 # This installs all third-party CTK plug-ins
186 mitkFunctionInstallThirdPartyCTKPlugins(${_APP_PLUGINS} EXCLUDE ${_APP_EXCLUDE_PLUGINS})
188 if(COMMAND BlueBerryApplicationInstallHook)
189 set(_real_app_plugins ${_APP_PLUGINS})
190 if(_APP_EXCLUDE_PLUGINS)
191 list(REMOVE_ITEM _real_app_plugins ${_APP_EXCLUDE_PLUGINS})
193 BlueBerryApplicationInstallHook(APP_NAME ${_APP_NAME} PLUGINS ${_real_app_plugins})
196 # Install the executable
197 MITK_INSTALL_TARGETS(EXECUTABLES ${_APP_NAME} LIBRARY_DIRS ${_APP_LIBRARY_DIRS} GLOB_PLUGINS )
199 if(NOT _APP_NO_PROVISIONING)
200 # Install the provisioning file
201 mitkFunctionInstallProvisioningFiles(${_prov_file})
204 # On Linux, create a shell script to start a relocatable application
205 if(UNIX AND NOT APPLE)
206 install(PROGRAMS "${MITK_SOURCE_DIR}/
CMake/RunInstalledApp.sh
" DESTINATION ".
" RENAME ${_APP_NAME}.sh)
209 # Tell cpack the executables that you want in the start menu as links
210 set(MITK_CPACK_PACKAGE_EXECUTABLES ${MITK_CPACK_PACKAGE_EXECUTABLES} "${_APP_NAME};${_APP_DESCRIPTION}
" CACHE INTERNAL "Collecting windows shortcuts to executables
")
216 function(FunctionCreateBlueBerryApplication)
FunctionCreateBlueBerryApplication()
static bool in(Reader::Char c, Reader::Char c1, Reader::Char c2, Reader::Char c3, Reader::Char c4)
mitkFunctionCreateBlueBerryApplication()
This function will create a BlueBerry application together with all necessary provisioning and config...