diff --git a/CMake/BuildConfigurations/MinimalCmdApps.cmake b/CMake/BuildConfigurations/CoreCmdApps.cmake similarity index 70% rename from CMake/BuildConfigurations/MinimalCmdApps.cmake rename to CMake/BuildConfigurations/CoreCmdApps.cmake index 5831991dc7..09a25933dd 100644 --- a/CMake/BuildConfigurations/MinimalCmdApps.cmake +++ b/CMake/BuildConfigurations/CoreCmdApps.cmake @@ -1,5 +1,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/Minimal.cmake) +set(MITK_WHITELIST "CoreCmdApps" CACHE STRING "" FORCE) + if(NOT MITK_USE_SUPERBUILD) set(BUILD_CoreCmdApps ON CACHE BOOL "" FORCE) endif() diff --git a/CMake/FixMacOSInstaller.cmake b/CMake/FixMacOSInstaller.cmake index bc3ebc5f69..c60ca34ebd 100644 --- a/CMake/FixMacOSInstaller.cmake +++ b/CMake/FixMacOSInstaller.cmake @@ -1,52 +1,41 @@ set(bundle_path "${CMAKE_INSTALL_PREFIX}/${_bundle_dest_dir}/../..") get_filename_component(bundle_path ${bundle_path} REALPATH) ############################# # (1) Fix Qt-related issues # ############################# # Compile list of Qt frameworks in bundle unset(qt_frameworks) file(GLOB qt_framework_paths "${bundle_path}/Contents/Frameworks/Qt*.framework") foreach(qt_framework_path ${qt_framework_paths}) get_filename_component(qt_framework ${qt_framework_path} NAME_WE) list(APPEND qt_frameworks ${qt_framework}) endforeach() # For each Qt framework, change the style of dependencies to other # Qt frameworks from @executable_path to @rpath. The install name tool # only changes existing dependencies. foreach(qt_framework ${qt_frameworks}) set(in "${bundle_path}/Contents/Frameworks/${qt_framework}.framework/Versions/5/${qt_framework}") foreach(other_qt_framework ${qt_frameworks}) set(from "@executable_path/../Frameworks/${other_qt_framework}.framework/Versions/5/${other_qt_framework}") set(to "@rpath/${other_qt_framework}.framework/Versions/5/${other_qt_framework}") execute_process(COMMAND install_name_tool -change ${from} ${to} ${in}) endforeach() endforeach() # Do the same for QtWebEngineProcess set(qtwebengineprocess_path "${bundle_path}/Contents/Frameworks/QtWebEngineCore.framework/Helpers/QtWebEngineProcess.app/Contents/MacOS/QtWebEngineProcess") foreach(qt_framework ${qt_frameworks}) set(from "@executable_path/../Frameworks/${qt_framework}.framework/Versions/5/${qt_framework}") set(to "@rpath/${qt_framework}.framework/Versions/5/${qt_framework}") execute_process(COMMAND install_name_tool -change ${from} ${to} ${qtwebengineprocess_path}) endforeach() # Add corresponding rpath entries to the actual application and QtWebEngineProcess. # The install name tool returns an error if an entry is already present. get_filename_component(app ${bundle_path} NAME_WE) set(app_path "${bundle_path}/Contents/MacOS/${app}") execute_process(COMMAND install_name_tool -add_rpath "@executable_path/../Frameworks" ${app_path} ERROR_QUIET) execute_process(COMMAND install_name_tool -add_rpath "@executable_path/../../../../.." ${qtwebengineprocess_path} ERROR_QUIET) - -################################################## -# (2) Fix hard dependencies to auto-load modules # -################################################## - -# Create symlinks to auto-load modules in MitkCore directory -file(GLOB autoload_module_paths "${bundle_path}/Contents/MacOS/MitkCore/*.dylib") -foreach(autoload_module_path ${autoload_module_paths}) - get_filename_component(autoload_module ${autoload_module_path} NAME) - execute_process(COMMAND ln -s MitkCore/${autoload_module} WORKING_DIRECTORY "${bundle_path}/Contents/MacOS") -endforeach() diff --git a/CMake/Whitelists/CoreCmdApps.cmake b/CMake/Whitelists/CoreCmdApps.cmake new file mode 100644 index 0000000000..ccc34d77f7 --- /dev/null +++ b/CMake/Whitelists/CoreCmdApps.cmake @@ -0,0 +1,25 @@ +include(${CMAKE_CURRENT_LIST_DIR}/Minimal.cmake) + +list(APPEND enabled_modules + AlgorithmsExt + Annotation + CommandLine + ContourModel + CoreCmdApps + DataTypesExt + DICOMPM + DICOMPMIO + DICOMQI + DICOMReader + DICOMReaderServices + DicomRT + DicomRTIO + DICOMSegIO + ModelFit + Multilabel + MultilabelIO + LegacyGL + SceneSerialization + SceneSerializationBase +) + diff --git a/CMake/Whitelists/MinimalCmdApps.cmake b/CMake/Whitelists/MinimalCmdApps.cmake deleted file mode 100644 index 15b5d443ea..0000000000 --- a/CMake/Whitelists/MinimalCmdApps.cmake +++ /dev/null @@ -1,6 +0,0 @@ -include(${CMAKE_CURRENT_LIST_DIR}/Minimal.cmake) - -list(APPEND enabled_modules - CommandLine - CoreCmdApps -) diff --git a/CMake/mitkFunctionCreateCommandLineApp.cmake b/CMake/mitkFunctionCreateCommandLineApp.cmake index 5c7d442fdd..139d6d53ef 100644 --- a/CMake/mitkFunctionCreateCommandLineApp.cmake +++ b/CMake/mitkFunctionCreateCommandLineApp.cmake @@ -1,99 +1,55 @@ #! #! Create a Command Line App. #! #! \brief This function will create a command line executable and the scripts required to run it #! #! \param NAME (required) Name of the command line app #! \param DEPENDS (optional) Required MITK modules beyond MitkCommandLine #! \param PACKAGE_DEPENDS (optional) list of "packages" this command line app depends on (e.g. ITK, VTK, etc.) #! \param CPP_FILES (optional) list of cpp files, if it is not given NAME.cpp is assumed #! #! Assuming that there exists a file called MyApp.cpp, an example call looks like: #! \code #! mitkFunctionCreateCommandLineApp( #! NAME MyApp #! DEPENDS MitkCore MitkPlanarFigure #! PACKAGE_DEPENDS ITK VTK #! ) #! \endcode #! function(mitkFunctionCreateCommandLineApp) set(_function_params NAME # Name of the command line app ) set(_function_multiparams DEPENDS # list of modules this command line app depends on PACKAGE_DEPENDS # list of "packages" this command line app depends on (e.g. ITK, VTK, etc.) CPP_FILES # (optional) list of cpp files, if it is not given NAME.cpp is assumed ) set(_function_options WARNINGS_NO_ERRORS ) cmake_parse_arguments(CMDAPP "${_function_options}" "${_function_params}" "${_function_multiparams}" ${ARGN}) if(NOT CMDAPP_NAME) message(FATAL_ERROR "NAME argument cannot be empty.") endif() if(NOT CMDAPP_CPP_FILES) set(CMDAPP_CPP_FILES ${CMDAPP_NAME}.cpp) endif() if(CMDAPP_WARNINGS_NO_ERRORS) LIST(APPEND _CMDAPP_OPTIONS WARNINGS_NO_ERRORS) endif() mitk_create_executable(${CMDAPP_NAME} DEPENDS MitkCommandLine ${CMDAPP_DEPENDS} PACKAGE_DEPENDS ${CMDAPP_PACKAGE_DEPENDS} CPP_FILES ${CMDAPP_CPP_FILES} ${_CMDAPP_OPTIONS} ) - MITK_INSTALL_TARGETS(EXECUTABLES ${EXECUTABLE_TARGET} ) - - if(EXECUTABLE_IS_ENABLED) - - # On Linux, create a shell script to start a relocatable application - if(UNIX AND NOT APPLE) - install(PROGRAMS "${MITK_SOURCE_DIR}/CMake/RunInstalledApp.sh" DESTINATION "." RENAME ${EXECUTABLE_TARGET}.sh) - endif() - - get_target_property(_is_bundle ${EXECUTABLE_TARGET} MACOSX_BUNDLE) - - if(APPLE) - if(_is_bundle) - set(_target_locations ${EXECUTABLE_TARGET}.app) - set(${_target_locations}_qt_plugins_install_dir ${EXECUTABLE_TARGET}.app/Contents/MacOS) - set(_bundle_dest_dir ${EXECUTABLE_TARGET}.app/Contents/MacOS) - set(_qt_plugins_for_current_bundle ${EXECUTABLE_TARGET}.app/Contents/MacOS) - set(_qt_conf_install_dirs ${EXECUTABLE_TARGET}.app/Contents/Resources) - install(TARGETS ${EXECUTABLE_TARGET} BUNDLE DESTINATION . ) - else() - if(NOT MACOSX_BUNDLE_NAMES) - set(_qt_conf_install_dirs bin) - set(_target_locations bin/${EXECUTABLE_TARGET}) - set(${_target_locations}_qt_plugins_install_dir bin) - install(TARGETS ${EXECUTABLE_TARGET} RUNTIME DESTINATION bin) - else() - foreach(bundle_name ${MACOSX_BUNDLE_NAMES}) - list(APPEND _qt_conf_install_dirs ${bundle_name}.app/Contents/Resources) - set(_current_target_location ${bundle_name}.app/Contents/MacOS/${EXECUTABLE_TARGET}) - list(APPEND _target_locations ${_current_target_location}) - set(${_current_target_location}_qt_plugins_install_dir ${bundle_name}.app/Contents/MacOS) - message( " set(${_current_target_location}_qt_plugins_install_dir ${bundle_name}.app/Contents/MacOS) ") - - install(TARGETS ${EXECUTABLE_TARGET} RUNTIME DESTINATION ${bundle_name}.app/Contents/MacOS/) - endforeach() - endif() - endif() - else() - set(_target_locations bin/${EXECUTABLE_TARGET}${CMAKE_EXECUTABLE_SUFFIX}) - set(${_target_locations}_qt_plugins_install_dir bin) - set(_qt_conf_install_dirs bin) - install(TARGETS ${EXECUTABLE_TARGET} RUNTIME DESTINATION bin) - endif() - endif() endfunction() diff --git a/CMake/mitkInstallRules.cmake b/CMake/mitkInstallRules.cmake index 0b02b0bc21..ec850c1efc 100644 --- a/CMake/mitkInstallRules.cmake +++ b/CMake/mitkInstallRules.cmake @@ -1,109 +1,152 @@ # Install MITK icon and logo MITK_INSTALL(FILES "${MITK_SOURCE_DIR}/mitk.ico" "${MITK_SOURCE_DIR}/mitk.bmp") # Helper vars if(WIN32) set(_prefix "") set(_ext ".dll") elseif(UNIX) set(_prefix "lib") if(APPLE) set(_ext ".dylib") else() set(_ext ".so") endif() endif() +# Install MITK executables including auto-load modules + +get_property(_mitk_executable_targets GLOBAL PROPERTY MITK_EXECUTABLE_TARGETS) +if(_mitk_executable_targets) + get_property(_mitk_module_targets GLOBAL PROPERTY MITK_MODULE_TARGETS) + foreach(_mitk_module_target ${_mitk_module_targets}) + if(TARGET ${_mitk_module_target}) + get_target_property(_mitk_autoload_targets ${_mitk_module_target} MITK_AUTOLOAD_TARGETS) + if (_mitk_autoload_targets) + foreach(_mitk_autoload_target ${_mitk_autoload_targets}) + get_target_property(_mitk_autoload_directory ${_mitk_autoload_target} MITK_AUTOLOAD_DIRECTORY) + if (_mitk_autoload_directory) + if(WIN32) + get_target_property(_target_location ${_mitk_autoload_target} RUNTIME_OUTPUT_DIRECTORY) + else() + get_target_property(_target_location ${_mitk_autoload_target} LIBRARY_OUTPUT_DIRECTORY) + endif() + if(NOT CMAKE_CFG_INTDIR STREQUAL ".") + set(_target_location "${_target_location}/Release") + endif() + set(_mitk_autoload_target_filename "${_prefix}${_mitk_autoload_target}${_ext}") + set(_mitk_autoload_target_filepath "${_target_location}/${_mitk_autoload_target_filename}") + set(_install_DESTINATION "${_mitk_autoload_directory}") + MITK_INSTALL(FILES ${_mitk_autoload_target_filepath}) + if(UNIX AND NOT APPLE) + install(CODE "file(RPATH_REMOVE FILE \"\${CMAKE_INSTALL_PREFIX}/bin/${_mitk_autoload_directory}/${_mitk_autoload_target_filename}\")") + endif() + endif() + endforeach() + endif() + endif() + endforeach() + + set(_install_DESTINATION "") + + foreach(_mitk_executable_target ${_mitk_executable_targets}) + MITK_INSTALL_TARGETS(EXECUTABLES ${_mitk_executable_target} GLOB_PLUGINS) + if(UNIX AND NOT APPLE) + install(PROGRAMS "${MITK_SOURCE_DIR}/CMake/RunInstalledApp.sh" DESTINATION "." RENAME ${_mitk_executable_target}.sh) + endif() + endforeach() +endif() + # Install PythonQt if(MITK_USE_Python3 AND PythonQt_DIR) set(_python_qt_lib "${PythonQt_DIR}/") if(WIN32) set(_python_qt_lib "${_python_qt_lib}bin") else() set(_python_qt_lib "${_python_qt_lib}lib") endif() set(_python_qt_lib "${_python_qt_lib}/${_prefix}PythonQt${_ext}") MITK_INSTALL(FILES ${_python_qt_lib}) endif() # Install Qt plugins if(MITK_USE_Qt5) get_property(_qmake_location TARGET ${Qt5Core_QMAKE_EXECUTABLE} PROPERTY IMPORT_LOCATION) get_filename_component(_qmake_path ${_qmake_location} DIRECTORY) set(_install_DESTINATION "plugins/sqldrivers") MITK_INSTALL(FILES "${_qmake_path}/../plugins/sqldrivers/${_prefix}qsqlite${_ext}") set(_install_DESTINATION "plugins/imageformats") MITK_INSTALL(FILES "${_qmake_path}/../plugins/imageformats/${_prefix}qsvg${_ext}") set(_install_DESTINATION "plugins/iconengines") MITK_INSTALL(FILES "${_qmake_path}/../plugins/iconengines/${_prefix}qsvgicon${_ext}") # Install platform-specific Qt plugins set(_install_DESTINATION "plugins/platforms") if(WIN32) MITK_INSTALL(FILES "${_qmake_path}/../plugins/platforms/qwindows.dll") elseif(APPLE) MITK_INSTALL(FILES "${_qmake_path}/../plugins/platforms/libqcocoa.dylib") elseif(UNIX) MITK_INSTALL(FILES "${_qmake_path}/../plugins/platforms/libqxcb.so") set(_install_DESTINATION "plugins/xcbglintegrations") MITK_INSTALL(FILES "${_qmake_path}/../plugins/xcbglintegrations/libqxcb-glx-integration.so") endif() # Install platform-specific Qt styles set(_install_DESTINATION "plugins/styles") if(WIN32) MITK_INSTALL(FILES "${_qmake_path}/../plugins/styles/qwindowsvistastyle.dll") elseif(APPLE) MITK_INSTALL(FILES "${_qmake_path}/../plugins/styles/libqmacstyle.dylib") endif() # Install Qt WebEngine if(APPLE) set(_install_DESTINATION "../Frameworks/QtWebEngineCore.framework") get_filename_component(_real_path "${_qmake_path}/../lib/QtWebEngineCore.framework/Helpers" REALPATH) MITK_INSTALL(DIRECTORY ${_real_path} USE_SOURCE_PERMISSIONS) # Translations are included in the Resources directory of # QtWebEngineCore.framework and are installed by default. else() set(_install_DESTINATION "") if(WIN32) MITK_INSTALL(PROGRAMS "${_qmake_path}/QtWebEngineProcess.exe") elseif(UNIX) MITK_INSTALL(PROGRAMS "${_qmake_path}/../libexec/QtWebEngineProcess") endif() MITK_INSTALL(DIRECTORY "${_qmake_path}/../resources") set(_install_DESTINATION "translations") MITK_INSTALL(DIRECTORY "${_qmake_path}/../translations/qtwebengine_locales") endif() endif() set(_install_DESTINATION "") # Install MatchPoint binaries that are not auto-detected if(MITK_USE_MatchPoint) MITK_INSTALL(DIRECTORY "${MITK_EXTERNAL_PROJECT_PREFIX}/bin/" FILES_MATCHING PATTERN "MapUtilities*") MITK_INSTALL(DIRECTORY "${MITK_EXTERNAL_PROJECT_PREFIX}/bin/" FILES_MATCHING PATTERN "MapAlgorithms*") endif() # IMPORTANT: Restore default install destination! Do not edit this file beyond this line! set(_install_DESTINATION "") diff --git a/CMake/mitkMacroCreateExecutable.cmake b/CMake/mitkMacroCreateExecutable.cmake index b5138cddc0..6f3a3048b0 100644 --- a/CMake/mitkMacroCreateExecutable.cmake +++ b/CMake/mitkMacroCreateExecutable.cmake @@ -1,111 +1,112 @@ ################################################################## # # MITK_CREATE_EXECUTABLE # #! Creates an executable with MITK dependencies and batch files #! for proper application start-up. #! #! USAGE: #! #! \code #! MITK_CREATE_EXECUTABLE( [] #! [DEPENDS ] #! [PACKAGE_DEPENDS ] #! [INCLUDE_DIRS ] #! [TARGET_DEPENDS #! [WARNINGS_NO_ERRORS] #! \endcode #! #! \param EXECUTABLE_NAME The name for the new executable target ################################################################## macro(mitk_create_executable) set(_macro_params VERSION # version number, e.g. "1.2.0" FILES_CMAKE # file name of a CMake file setting source list variables # (defaults to files.cmake) DESCRIPTION # a description for the executable ) set(_macro_multiparams SUBPROJECTS # list of CDash labels INCLUDE_DIRS # additional include dirs DEPENDS # list of modules this module depends on PACKAGE_DEPENDS # list of "packages" this module depends on (e.g. Qt, VTK, etc.) TARGET_DEPENDS # list of CMake targets this executable should depend on ADDITIONAL_LIBS # list of additional libraries linked to this executable CPP_FILES # (optional) list of cpp files ) set(_macro_options NO_INIT # do not create CppMicroServices initialization code NO_FEATURE_INFO # do not create a feature info by calling add_feature_info() NO_BATCH_FILE # do not create batch files on Windows WARNINGS_NO_ERRORS # do not treat compiler warnings as errors ) cmake_parse_arguments(EXEC "${_macro_options}" "${_macro_params}" "${_macro_multiparams}" ${ARGN}) set(_EXEC_OPTIONS EXECUTABLE) if(EXEC_NO_INIT) list(APPEND _EXEC_OPTIONS NO_INIT) endif() if(EXEC_WARNINGS_NO_ERRORS) list(APPEND _EXEC_OPTIONS WARNINGS_NO_ERRORS) endif() if(EXEC_NO_FEATURE_INFO) list(APPEND _EXEC_OPTIONS NO_FEATURE_INFO) endif() mitk_create_module(${EXEC_UNPARSED_ARGUMENTS} SUBPROJECTS ${EXEC_SUBPROJECTS} VERSION ${EXEC_VERSION} INCLUDE_DIRS ${EXEC_INCLUDE_DIRS} DEPENDS ${EXEC_DEPENDS} PACKAGE_DEPENDS ${EXEC_PACKAGE_DEPENDS} TARGET_DEPENDS ${EXEC_TARGET_DEPENDS} ADDITIONAL_LIBS ${EXEC_ADDITIONAL_LIBS} FILES_CMAKE ${EXEC_FILES_CMAKE} CPP_FILES ${EXEC_CPP_FILES} DESCRIPTION "${DESCRIPTION}" ${_EXEC_OPTIONS} ) set(EXECUTABLE_IS_ENABLED ${MODULE_IS_ENABLED}) set(EXECUTABLE_TARGET ${MODULE_TARGET}) - if(MODULE_IS_ENABLED) + if(EXECUTABLE_IS_ENABLED) + set_property(GLOBAL APPEND PROPERTY MITK_EXECUTABLE_TARGETS ${EXECUTABLE_TARGET}) # Add meta dependencies (e.g. on auto-load modules from depending modules) if(TARGET ${CMAKE_PROJECT_NAME}-autoload) add_dependencies(${MODULE_TARGET} ${CMAKE_PROJECT_NAME}-autoload) endif() # Create batch and VS user files for Windows platforms include(mitkFunctionCreateWindowsBatchScript) if(WIN32) set(_batch_file_in "${CMAKE_CURRENT_SOURCE_DIR}/${MODULE_TARGET}.bat.in") if(NOT EXISTS "${_batch_file_in}") set(_batch_file_in "${MITK_CMAKE_DIR}/StartApp.bat.in") endif() if(CMAKE_RUNTIME_OUTPUT_DIRECTORY) set(_batch_file_out_dir "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") else() set(_batch_file_out_dir "${CMAKE_CURRENT_BINARY_DIR}") endif() if(NOT EXEC_NO_BATCH_FILE) if(NOT EXEC_NAME) set(EXEC_NAME ${MODULE_TARGET}) endif() foreach(BUILD_TYPE debug release) mitkFunctionCreateWindowsBatchScript( ${_batch_file_in} ${_batch_file_out_dir}/${MODULE_TARGET}_${BUILD_TYPE}.bat ${BUILD_TYPE} ) endforeach() endif() mitkFunctionConfigureVisualStudioUserProjectFile( NAME ${MODULE_TARGET} ) endif() endif() endmacro() diff --git a/CMake/mitkMacroInstallHelperApp.cmake b/CMake/mitkMacroInstallHelperApp.cmake index f72bf92379..ddfe252c9c 100644 --- a/CMake/mitkMacroInstallHelperApp.cmake +++ b/CMake/mitkMacroInstallHelperApp.cmake @@ -1,109 +1,74 @@ #! MITK specific cross plattform install macro #! #! Usage: MITK_INSTALL_HELPER_APP(target1 [target2] ....) #! macro(MITK_INSTALL_HELPER_APP) cmake_parse_arguments(_install "GLOB_PLUGINS" "" "TARGETS;EXECUTABLES;PLUGINS;LIBRARY_DIRS" ${ARGN}) list(APPEND _install_TARGETS ${_install_DEFAULT_ARGS}) # TODO: how to supply to correct intermediate directory?? # CMAKE_CFG_INTDIR is not expanded to actual values inside the install(CODE "...") macro ... set(intermediate_dir .) if(WIN32) set(intermediate_dir Release) endif() mitkFunctionGetLibrarySearchPaths(DIRS ${intermediate_dir}) if(APPLE) list(APPEND DIRS "/usr/lib") endif(APPLE) - if(QT_LIBRARY_DIR MATCHES "^(/lib|/lib32|/lib64|/usr/lib|/usr/lib32|/usr/lib64|/usr/X11R6)(/.*)?$") - set(_qt_is_system_qt 1) - endif() - foreach(_target ${_install_EXECUTABLES}) - - set(_qt_plugins_install_dirs "") set(_qt_conf_install_dirs "") set(_target_locations "") get_filename_component(_target_name ${_target} NAME) if(APPLE) if(NOT MACOSX_BUNDLE_NAMES) set(_qt_conf_install_dirs bin) set(_target_locations bin/${_target_name}) - set(${_target_locations}_qt_plugins_install_dir bin) install(PROGRAMS ${_target} DESTINATION bin) else() foreach(bundle_name ${MACOSX_BUNDLE_NAMES}) list(APPEND _qt_conf_install_dirs ${bundle_name}.app/Contents/Resources) set(_current_target_location ${bundle_name}.app/Contents/MacOS/${_target_name}) list(APPEND _target_locations ${_current_target_location}) - set(${_current_target_location}_qt_plugins_install_dir ${bundle_name}.app/Contents/MacOS) - install(PROGRAMS ${_target} DESTINATION ${bundle_name}.app/Contents/MacOS/) endforeach() endif(NOT MACOSX_BUNDLE_NAMES) else() set(_target_location bin/${_target_name}) - set(${_target_location}_qt_plugins_install_dir bin) set(_qt_conf_install_dirs bin) install(PROGRAMS ${_target} DESTINATION bin) if(UNIX AND NOT WIN32) # Remove the rpath from helper applications. We assume that all dependencies # are installed into the same location as the helper application. install(CODE "file(RPATH_REMOVE FILE \"\${CMAKE_INSTALL_PREFIX}/${_target_location}\")") endif() endif() foreach(_target_location ${_target_locations}) - if(NOT _qt_is_system_qt) - if(QT_PLUGINS_DIR) - if(WIN32) - install(DIRECTORY "${QT_PLUGINS_DIR}" - DESTINATION ${${_target_location}_qt_plugins_install_dir} - CONFIGURATIONS Release - FILES_MATCHING REGEX "[^4d]4?${CMAKE_SHARED_LIBRARY_SUFFIX}" - ) - - install(DIRECTORY "${QT_PLUGINS_DIR}" - DESTINATION ${${_target_location}_qt_plugins_install_dir} - CONFIGURATIONS Debug - FILES_MATCHING REGEX "d4?${CMAKE_SHARED_LIBRARY_SUFFIX}" - ) - else(WIN32) - # install everything, see bug 7143 - install(DIRECTORY "${QT_PLUGINS_DIR}" - DESTINATION ${${_target_location}_qt_plugins_install_dir} - FILES_MATCHING REGEX "${CMAKE_SHARED_LIBRARY_SUFFIX}" - ) - - endif(WIN32) - endif() - endif() _fixup_target() endforeach(_target_location) - if(NOT _qt_is_system_qt) - #-------------------------------------------------------------------------------- - # install a qt.conf file - # this inserts some cmake code into the install script to write the file + #-------------------------------------------------------------------------------- + # install a qt.conf file + # this inserts some cmake code into the install script to write the file + if(MITK_USE_Qt5) set(_qt_conf_plugin_install_prefix .) if(APPLE) set(_qt_conf_plugin_install_prefix ./MacOS) endif() foreach(_qt_conf_install_dir ${_qt_conf_install_dirs}) install(CODE "file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${_qt_conf_install_dir}/qt.conf\" \" [Paths] Prefix=${_qt_conf_plugin_install_prefix} \")") endforeach() endif() - endforeach() endmacro(MITK_INSTALL_HELPER_APP) diff --git a/CMake/mitkMacroInstallTargets.cmake b/CMake/mitkMacroInstallTargets.cmake index dbe1367269..68ffe8bcba 100644 --- a/CMake/mitkMacroInstallTargets.cmake +++ b/CMake/mitkMacroInstallTargets.cmake @@ -1,113 +1,71 @@ # # MITK specific cross plattform install macro # # Usage: MITK_INSTALL_TARGETS(target1 [target2] ....) # macro(MITK_INSTALL_TARGETS) cmake_parse_arguments(_install "GLOB_PLUGINS" "" "TARGETS;EXECUTABLES;PLUGINS;LIBRARY_DIRS" ${ARGN}) list(APPEND _install_TARGETS ${_install_DEFAULT_ARGS}) # TODO: how to supply the correct intermediate directory?? # CMAKE_CFG_INTDIR is not expanded to actual values inside the install(CODE "...") macro ... set(intermediate_dir .) if(WIN32) set(intermediate_dir Release) endif() - if(QT_LIBRARY_DIR MATCHES "^(/lib|/lib32|/lib64|/usr/lib|/usr/lib32|/usr/lib64|/usr/X11R6)(/.*)?$") - set(_qt_is_system_qt 1) - endif() - foreach(_target ${_install_EXECUTABLES}) - get_target_property(_is_bundle ${_target} MACOSX_BUNDLE) - set(_qt_plugins_install_dirs "") set(_qt_conf_install_dirs "") set(_target_locations "") if(APPLE) if(_is_bundle) set(_target_locations ${_target}.app) set(${_target_locations}_qt_plugins_install_dir ${_target}.app/Contents/MacOS) set(_bundle_dest_dir ${_target}.app/Contents/MacOS) - set(_qt_plugins_for_current_bundle ${_target}.app/Contents/MacOS) set(_qt_conf_install_dirs ${_target}.app/Contents/Resources) install(TARGETS ${_target} BUNDLE DESTINATION . ) else() if(NOT MACOSX_BUNDLE_NAMES) set(_qt_conf_install_dirs bin) set(_target_locations bin/${_target}) - set(${_target_locations}_qt_plugins_install_dir bin) install(TARGETS ${_target} RUNTIME DESTINATION bin) else() foreach(bundle_name ${MACOSX_BUNDLE_NAMES}) list(APPEND _qt_conf_install_dirs ${bundle_name}.app/Contents/Resources) set(_current_target_location ${bundle_name}.app/Contents/MacOS/${_target}) list(APPEND _target_locations ${_current_target_location}) - set(${_current_target_location}_qt_plugins_install_dir ${bundle_name}.app/Contents/MacOS) - message( " set(${_current_target_location}_qt_plugins_install_dir ${bundle_name}.app/Contents/MacOS) ") - install(TARGETS ${_target} RUNTIME DESTINATION ${bundle_name}.app/Contents/MacOS/) endforeach() endif() endif() else() set(_target_locations bin/${_target}${CMAKE_EXECUTABLE_SUFFIX}) - set(${_target_locations}_qt_plugins_install_dir bin) set(_qt_conf_install_dirs bin) install(TARGETS ${_target} RUNTIME DESTINATION bin) endif() foreach(_target_location ${_target_locations}) - if(NOT _qt_is_system_qt) - - if(QT_PLUGINS_DIR) - if(WIN32) - install(DIRECTORY "${QT_PLUGINS_DIR}" - DESTINATION ${${_target_location}_qt_plugins_install_dir} - CONFIGURATIONS Release - FILES_MATCHING REGEX "[^4d]4?${CMAKE_SHARED_LIBRARY_SUFFIX}" - ) - - install(DIRECTORY "${QT_PLUGINS_DIR}" - DESTINATION ${${_target_location}_qt_plugins_install_dir} - CONFIGURATIONS Debug - FILES_MATCHING REGEX "d4?${CMAKE_SHARED_LIBRARY_SUFFIX}" - ) - else(WIN32) - # install everything, see bug 7143 - install(DIRECTORY "${QT_PLUGINS_DIR}" - DESTINATION ${${_target_location}_qt_plugins_install_dir} - FILES_MATCHING REGEX "${CMAKE_SHARED_LIBRARY_SUFFIX}" - ) - - endif(WIN32) - - endif() - endif() _fixup_target() endforeach() - if(NOT _qt_is_system_qt) - - #-------------------------------------------------------------------------------- - # install a qt.conf file - # this inserts some cmake code into the install script to write the file + #-------------------------------------------------------------------------------- + # install a qt.conf file + # this inserts some cmake code into the install script to write the file + if(MITK_USE_Qt5) set(_qt_conf_plugin_install_prefix .) if(APPLE) set(_qt_conf_plugin_install_prefix ./MacOS) endif() foreach(_qt_conf_install_dir ${_qt_conf_install_dirs}) install(CODE "file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${_qt_conf_install_dir}/qt.conf\" \" -[Paths] -Prefix=${_qt_conf_plugin_install_prefix} -\")") + [Paths] + Prefix=${_qt_conf_plugin_install_prefix} + \")") endforeach() - endif() - endforeach() - endmacro()