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 NO_PROVISIONING (option) Do not create provisioning files. 19 #! \param NO_INSTALL (option) Do not install this executable 21 #! Assuming that there exists a file called <code>MyApp.cpp</code>, an example call looks like: 23 #! mitkFunctionCreateBlueBerryApplication( 25 #! DESCRIPTION "MyApp - New ways to explore medical data" 26 #! EXCLUDE_PLUGINS org.mitk.gui.qt.extapplication 32 cmake_parse_arguments(_APP
"NO_PROVISIONING;NO_INSTALL" "NAME;DESCRIPTION" "SOURCES;PLUGINS;EXCLUDE_PLUGINS;LINK_LIBRARIES;LIBRARY_DIRS" ${ARGN})
35 message(FATAL_ERROR
"NAME argument cannot be empty.")
39 set(_APP_SOURCES ${_APP_NAME}.cpp)
43 ctkFunctionGetAllPluginTargets(_APP_PLUGINS)
45 set(_plugins ${_APP_PLUGINS})
47 foreach(_plugin ${_plugins})
48 string(REPLACE
"." "_" _plugin_target ${_plugin})
49 list(APPEND _APP_PLUGINS ${_plugin_target})
52 # get all plug-in dependencies 53 ctkFunctionGetPluginDependencies(_plugin_deps PLUGINS ${_APP_PLUGINS}
ALL)
54 # add the dependencies to the list of application plug-ins
55 list(APPEND _APP_PLUGINS ${_plugin_deps})
58 # ----------------------------------------------------------------------- 59 # Set up include and link dirs for the executable 60 # ----------------------------------------------------------------------- 63 ${org_blueberry_core_runtime_INCLUDE_DIRS}
66 # -----------------------------------------------------------------------
67 # Add executable icon (Windows)
68 # ----------------------------------------------------------------------- 69 set(WINDOWS_ICON_RESOURCE_FILE
"")
71 if(EXISTS
"${CMAKE_CURRENT_SOURCE_DIR}/icons/${_APP_NAME}.rc")
72 set(WINDOWS_ICON_RESOURCE_FILE
"${CMAKE_CURRENT_SOURCE_DIR}/icons/${_APP_NAME}.rc")
76 # ----------------------------------------------------------------------- 77 # Create the executable and link libraries 78 # ----------------------------------------------------------------------- 80 set(_app_compile_flags )
82 set(_app_compile_flags
"${_app_compile_flags} -DPOCO_NO_UNWINDOWS -DWIN32_LEAN_AND_MEAN")
85 if(MITK_SHOW_CONSOLE_WINDOW)
86 add_executable(${_APP_NAME} MACOSX_BUNDLE ${_APP_SOURCES} ${WINDOWS_ICON_RESOURCE_FILE})
88 add_executable(${_APP_NAME} MACOSX_BUNDLE WIN32 ${_APP_SOURCES} ${WINDOWS_ICON_RESOURCE_FILE})
91 if(NOT CMAKE_CURRENT_SOURCE_DIR MATCHES "^${CMAKE_SOURCE_DIR}.*
") 92 foreach(MITK_EXTENSION_DIR ${MITK_EXTENSION_DIRS}) 93 if(CMAKE_CURRENT_SOURCE_DIR MATCHES "^${MITK_EXTENSION_DIR}.*
") 94 get_filename_component(MITK_EXTENSION_ROOT_FOLDER ${MITK_EXTENSION_DIR} NAME) 95 set_property(TARGET ${_APP_NAME} PROPERTY FOLDER "${MITK_EXTENSION_ROOT_FOLDER}/Applications
") 100 set_property(TARGET ${_APP_NAME} PROPERTY FOLDER "${MITK_ROOT_FOLDER}/Applications
") 103 mitk_use_modules(TARGET ${_APP_NAME} MODULES MitkAppUtil) 105 set_target_properties(${_APP_NAME} PROPERTIES 106 COMPILE_FLAGS "${_app_compile_flags}
") 108 target_link_libraries(${_APP_NAME} PRIVATE org_blueberry_core_runtime ${_APP_LINK_LIBRARIES}) 110 target_link_libraries(${_APP_NAME} PRIVATE ${QT_QTMAIN_LIBRARY}) 113 # ----------------------------------------------------------------------- 114 # Add executable icon and bundle name (Mac) 115 # ----------------------------------------------------------------------- 117 if( _APP_DESCRIPTION) 118 set_target_properties(${_APP_NAME} PROPERTIES MACOSX_BUNDLE_NAME "${_APP_DESCRIPTION}
") 120 set_target_properties(${_APP_NAME} PROPERTIES MACOSX_BUNDLE_NAME "${_APP_NAME}
") 122 set(icon_name "icon.icns
") 123 set(icon_full_path "${CMAKE_CURRENT_SOURCE_DIR}/icons/${icon_name}
") 124 if(EXISTS "${icon_full_path}
") 125 set_target_properties(${_APP_NAME} PROPERTIES MACOSX_BUNDLE_ICON_FILE "${icon_name}
") 126 file(COPY ${icon_full_path} DESTINATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${_APP_NAME}.app/Contents/Resources/
") 127 INSTALL (FILES ${icon_full_path} DESTINATION "${_APP_NAME}.app/Contents/Resources/
") 131 # ----------------------------------------------------------------------- 132 # Set build time dependencies 133 # ----------------------------------------------------------------------- 135 # This ensures that all enabled plug-ins are up-to-date when the 136 # executable is build. 138 ctkMacroGetAllProjectTargetLibraries("${_APP_PLUGINS}
" _project_plugins) 139 if(_APP_EXCLUDE_PLUGINS AND _project_plugins) 140 set(_exclude_targets) 141 foreach(_exclude_plugin ${_APP_EXCLUDE_PLUGINS}) 142 string(REPLACE ".
" "_
" _exclude_target ${_exclude_plugin}) 143 list(APPEND _exclude_targets ${_exclude_target}) 145 list(REMOVE_ITEM _project_plugins ${_exclude_targets}) 148 add_dependencies(${_APP_NAME} ${_project_plugins}) 152 # ----------------------------------------------------------------------- 153 # Additional files needed for the executable 154 # ----------------------------------------------------------------------- 156 if(NOT _APP_NO_PROVISIONING) 158 # Create a provisioning file, listing all plug-ins 159 set(_prov_file "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${_APP_NAME}.provisioning
") 160 mitkFunctionCreateProvisioningFile(FILE ${_prov_file} 161 PLUGINS ${_APP_PLUGINS} 162 EXCLUDE_PLUGINS ${_APP_EXCLUDE_PLUGINS} 167 # Create a .ini file for initial parameters 168 if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${_APP_NAME}.ini
") 169 configure_file(${_APP_NAME}.ini 170 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${_APP_NAME}.ini) 173 # Create batch and VS user files for Windows platforms 174 include(mitkFunctionCreateWindowsBatchScript) 177 set(template_name "start${_APP_NAME}.bat.in
") 178 if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${template_name}
") 179 foreach(BUILD_TYPE debug release) 180 mitkFunctionCreateWindowsBatchScript(${template_name} 181 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/start${_APP_NAME}_${BUILD_TYPE}.bat 185 mitkFunctionConfigureVisualStudioUserProjectFile( 190 # ----------------------------------------------------------------------- 192 # ----------------------------------------------------------------------- 194 if(NOT _APP_NO_INSTALL) 196 # This installs all third-party CTK plug-ins 197 mitkFunctionInstallThirdPartyCTKPlugins(${_APP_PLUGINS} EXCLUDE ${_APP_EXCLUDE_PLUGINS}) 199 if(COMMAND BlueBerryApplicationInstallHook) 200 set(_real_app_plugins ${_APP_PLUGINS}) 201 if(_APP_EXCLUDE_PLUGINS) 202 list(REMOVE_ITEM _real_app_plugins ${_APP_EXCLUDE_PLUGINS}) 204 BlueBerryApplicationInstallHook(APP_NAME ${_APP_NAME} PLUGINS ${_real_app_plugins}) 207 # Install the executable 208 MITK_INSTALL_TARGETS(EXECUTABLES ${_APP_NAME} LIBRARY_DIRS ${_APP_LIBRARY_DIRS} GLOB_PLUGINS ) 210 if(NOT _APP_NO_PROVISIONING) 211 # Install the provisioning file 212 mitkFunctionInstallProvisioningFiles(${_prov_file}) 215 # On Linux, create a shell script to start a relocatable application 216 if(UNIX AND NOT APPLE) 217 install(PROGRAMS "${MITK_SOURCE_DIR}/
CMake/RunInstalledApp.sh
" DESTINATION ".
" RENAME ${_APP_NAME}.sh) 220 # Tell cpack the executables that you want in the start menu as links 221 set(MITK_CPACK_PACKAGE_EXECUTABLES ${MITK_CPACK_PACKAGE_EXECUTABLES} "${_APP_NAME};${_APP_DESCRIPTION}
" CACHE INTERNAL "Collecting windows shortcuts to executables
") 227 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...