diff --git a/CMake/RunInstalledCmdLineApp.bat b/CMake/RunInstalledCmdLineApp.bat new file mode 100644 index 0000000000..9090f4aa90 --- /dev/null +++ b/CMake/RunInstalledCmdLineApp.bat @@ -0,0 +1 @@ +"%~dp0..\bin\%~n0.exe" %* diff --git a/CMake/RunInstalledCmdLineApp.sh b/CMake/RunInstalledCmdLineApp.sh new file mode 100644 index 0000000000..5eadd45fb7 --- /dev/null +++ b/CMake/RunInstalledCmdLineApp.sh @@ -0,0 +1,7 @@ +#!/bin/sh +binpath=$(dirname "$(dirname "$(readlink -f "$0")")") +appname=$(basename "$0" .sh) +export LD_LIBRARY_PATH="$binpath/bin":"$binpath/bin/plugins":"$LD_LIBRARY_PATH" +export QT_PLUGIN_PATH="$binpath/bin":"$binpath/bin/plugins" +export QT_QPA_PLATFORM=xcb +"$binpath/bin/$appname" "$@" diff --git a/CMake/mitkFunctionCreateCommandLineApp.cmake b/CMake/mitkFunctionCreateCommandLineApp.cmake index 949e57e848..ac4840e18a 100644 --- a/CMake/mitkFunctionCreateCommandLineApp.cmake +++ b/CMake/mitkFunctionCreateCommandLineApp.cmake @@ -1,58 +1,59 @@ #! #! 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 TARGET_DEPENDS (optional) list of additional CMake targets this command line app depends on #! \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.) TARGET_DEPENDS # list of additional CMake targets this command line app depends on 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} TARGET_DEPENDS ${TARGET_DEPENDS} CPP_FILES ${CMDAPP_CPP_FILES} ${_CMDAPP_OPTIONS} ) + set_target_properties(${EXECUTABLE_TARGET} PROPERTIES COMMAND_LINE_APP TRUE) endfunction() diff --git a/CMake/mitkInstallRules.cmake b/CMake/mitkInstallRules.cmake index f9a4271830..2aa56b530d 100644 --- a/CMake/mitkInstallRules.cmake +++ b/CMake/mitkInstallRules.cmake @@ -1,176 +1,184 @@ # 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}) get_target_property(_no_install ${_mitk_executable_target} NO_INSTALL) if(_no_install) continue() endif() MITK_INSTALL_TARGETS(EXECUTABLES ${_mitk_executable_target} GLOB_PLUGINS) + get_target_property(_command_line_app ${_mitk_executable_target} COMMAND_LINE_APP) + if(_command_line_app) + set(_source "RunInstalledCmdLineApp") + set(_destination "apps") + else() + set(_source "RunInstalledApp") + set(_destination ".") + endif() if(UNIX AND NOT APPLE) - install(PROGRAMS "${MITK_SOURCE_DIR}/CMake/RunInstalledApp.sh" DESTINATION "." RENAME "${_mitk_executable_target}.sh") + install(PROGRAMS "${MITK_SOURCE_DIR}/CMake/${_source}.sh" DESTINATION "${_destination}" RENAME "${_mitk_executable_target}.sh") elseif(WIN32) get_target_property(_win32_exec ${_mitk_executable_target} WIN32_EXECUTABLE) if(_win32_exec) - install(PROGRAMS "${MITK_SOURCE_DIR}/CMake/RunInstalledWin32App.bat" DESTINATION "." RENAME "${_mitk_executable_target}.bat") + install(PROGRAMS "${MITK_SOURCE_DIR}/CMake/RunInstalledWin32App.bat" DESTINATION "${_destination}" RENAME "${_mitk_executable_target}.bat") else() - install(PROGRAMS "${MITK_SOURCE_DIR}/CMake/RunInstalledApp.bat" DESTINATION "." RENAME "${_mitk_executable_target}.bat") + install(PROGRAMS "${MITK_SOURCE_DIR}/CMake/${_source}.bat" DESTINATION "${_destination}" RENAME "${_mitk_executable_target}.bat") endif() 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_Qt6) get_filename_component(_qmake_path "${QT_QMAKE_EXECUTABLE}" 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() # make sure resources and translations exist and try system location as well if(EXISTS "${_qmake_path}/../resources") MITK_INSTALL(DIRECTORY "${_qmake_path}/../resources") elseif(EXISTS "/usr/share/qt6/resources") MITK_INSTALL(DIRECTORY "/usr/share/qt6/resources") else() message(WARNING "No webengine resources found!") endif() set(_install_DESTINATION "translations") if(EXISTS "${_qmake_path}/../translations/qtwebengine_locales") MITK_INSTALL(DIRECTORY "${_qmake_path}/../translations/qtwebengine_locales") elseif(EXISTS "/usr/share/qt6/translations/qtwebengine_locales") MITK_INSTALL(DIRECTORY "/usr/share/qt6/translations/qtwebengine_locales") else() message(WARNING "No webengine translations found!") endif() 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 "")