2 # MITK specific cross plattform install macro
4 # Usage: MITK_INSTALL_TARGETS(target1 [target2] ....)
7 cmake_parse_arguments(_install "GLOB_PLUGINS" "" "TARGETS;EXECUTABLES;PLUGINS;LIBRARY_DIRS" ${ARGN})
8 list(APPEND _install_TARGETS ${_install_DEFAULT_ARGS})
10 # TODO: how to supply the correct intermediate directory??
11 # CMAKE_CFG_INTDIR is not expanded to actual values inside the install(CODE
"...") macro ...
12 set(intermediate_dir .)
13 if(WIN32 AND NOT MINGW)
14 set(intermediate_dir Release)
17 if(QT_LIBRARY_DIR MATCHES "^(/lib|/lib32|/lib64|/usr/lib|/usr/lib32|/usr/lib64|/usr/X11R6)(/.*)?$")
18 set(_qt_is_system_qt 1)
21 foreach(_target ${_install_EXECUTABLES})
23 get_target_property(_is_bundle ${_target} MACOSX_BUNDLE)
25 set(_qt_plugins_install_dirs
"")
26 set(_qt_conf_install_dirs "")
27 set(_target_locations "")
31 set(_target_locations ${_target}.app)
32 set(${_target_locations}_qt_plugins_install_dir ${_target}.app/Contents/MacOS)
33 set(_bundle_dest_dir ${_target}.app/Contents/MacOS)
34 set(_qt_plugins_for_current_bundle ${_target}.app/Contents/MacOS)
35 set(_qt_conf_install_dirs ${_target}.app/Contents/Resources)
36 install(TARGETS ${_target} BUNDLE DESTINATION . )
38 if(NOT MACOSX_BUNDLE_NAMES)
39 set(_qt_conf_install_dirs bin)
40 set(_target_locations bin/${_target})
41 set(${_target_locations}_qt_plugins_install_dir bin)
42 install(TARGETS ${_target} RUNTIME DESTINATION bin)
44 foreach(bundle_name ${MACOSX_BUNDLE_NAMES})
45 list(APPEND _qt_conf_install_dirs ${bundle_name}.app/Contents/Resources)
46 set(_current_target_location ${bundle_name}.app/Contents/MacOS/${_target})
47 list(APPEND _target_locations ${_current_target_location})
48 set(${_current_target_location}_qt_plugins_install_dir ${bundle_name}.app/Contents/MacOS)
49 message(
" set(${_current_target_location}_qt_plugins_install_dir ${bundle_name}.app/Contents/MacOS) ")
51 install(TARGETS ${_target} RUNTIME DESTINATION ${bundle_name}.app/Contents/MacOS/)
56 set(_target_locations bin/${_target}${CMAKE_EXECUTABLE_SUFFIX})
57 set(${_target_locations}_qt_plugins_install_dir bin)
58 set(_qt_conf_install_dirs bin)
59 install(TARGETS ${_target} RUNTIME DESTINATION bin)
62 foreach(_target_location ${_target_locations})
63 if(NOT _qt_is_system_qt)
67 install(DIRECTORY
"${QT_PLUGINS_DIR}"
68 DESTINATION ${${_target_location}_qt_plugins_install_dir}
69 CONFIGURATIONS Release
70 FILES_MATCHING REGEX
"[^4d]4?${CMAKE_SHARED_LIBRARY_SUFFIX}"
73 install(DIRECTORY
"${QT_PLUGINS_DIR}"
74 DESTINATION ${${_target_location}_qt_plugins_install_dir}
76 FILES_MATCHING REGEX
"d4?${CMAKE_SHARED_LIBRARY_SUFFIX}"
79 # install everything, see bug 7143
80 install(DIRECTORY
"${QT_PLUGINS_DIR}"
81 DESTINATION ${${_target_location}_qt_plugins_install_dir}
82 FILES_MATCHING REGEX
"${CMAKE_SHARED_LIBRARY_SUFFIX}"
92 if(NOT _qt_is_system_qt)
94 #--------------------------------------------------------------------------------
95 # install a qt.conf file
96 # this inserts some cmake code into the install script to write the file
97 set(_qt_conf_plugin_install_prefix .)
99 set(_qt_conf_plugin_install_prefix ./MacOS)
102 foreach(_qt_conf_install_dir ${_qt_conf_install_dirs})
103 install(CODE
"file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${_qt_conf_install_dir}/qt.conf\" \"
105 Prefix=${_qt_conf_plugin_install_prefix}