1 #! MITK specific cross plattform install macro
3 #! Usage: MITK_INSTALL_HELPER_APP(target1 [target2] ....)
6 cmake_parse_arguments(_install "GLOB_PLUGINS" "" "TARGETS;EXECUTABLES;PLUGINS;LIBRARY_DIRS" ${ARGN})
7 list(APPEND _install_TARGETS ${_install_DEFAULT_ARGS})
9 # TODO: how to supply to correct intermediate directory??
10 # CMAKE_CFG_INTDIR is not expanded to actual values inside the install(CODE
"...") macro ...
11 set(intermediate_dir .)
12 if(WIN32 AND NOT MINGW)
13 set(intermediate_dir Release)
19 list(APPEND DIRS "/usr/lib")
22 if(QT_LIBRARY_DIR MATCHES "^(/lib|/lib32|/lib64|/usr/lib|/usr/lib32|/usr/lib64|/usr/X11R6)(/.*)?$")
23 set(_qt_is_system_qt 1)
26 foreach(_target ${_install_EXECUTABLES})
28 set(_qt_plugins_install_dirs
"")
29 set(_qt_conf_install_dirs "")
30 set(_target_locations "")
32 get_filename_component(_target_name ${_target}
NAME)
35 if(NOT MACOSX_BUNDLE_NAMES)
36 set(_qt_conf_install_dirs bin)
37 set(_target_locations bin/${_target_name})
38 set(${_target_locations}_qt_plugins_install_dir bin)
39 install(PROGRAMS ${_target} DESTINATION bin)
41 foreach(bundle_name ${MACOSX_BUNDLE_NAMES})
42 list(APPEND _qt_conf_install_dirs ${bundle_name}.app/Contents/Resources)
43 set(_current_target_location ${bundle_name}.app/Contents/MacOS/${_target_name})
44 list(APPEND _target_locations ${_current_target_location})
45 set(${_current_target_location}_qt_plugins_install_dir ${bundle_name}.app/Contents/MacOS)
47 install(PROGRAMS ${_target} DESTINATION ${bundle_name}.app/Contents/MacOS/)
49 endif(NOT MACOSX_BUNDLE_NAMES)
51 set(_target_location bin/${_target_name})
52 set(${_target_location}_qt_plugins_install_dir bin)
53 set(_qt_conf_install_dirs bin)
54 install(PROGRAMS ${_target} DESTINATION bin)
55 if(UNIX AND NOT WIN32)
56 # Remove the rpath from helper applications. We assume that all dependencies
57 # are installed into the same location as the helper application.
58 install(CODE
"file(RPATH_REMOVE
59 FILE \"\${CMAKE_INSTALL_PREFIX}/${_target_location}\")")
63 foreach(_target_location ${_target_locations})
64 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}"
89 endforeach(_target_location)
91 if(NOT _qt_is_system_qt)
92 #--------------------------------------------------------------------------------
93 # install a qt.conf file
94 # this inserts some cmake code into the install script to write the file
95 set(_qt_conf_plugin_install_prefix .)
97 set(_qt_conf_plugin_install_prefix ./MacOS)
99 foreach(_qt_conf_install_dir ${_qt_conf_install_dirs})
100 install(CODE
"file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${_qt_conf_install_dir}/qt.conf\" \"
102 Prefix=${_qt_conf_plugin_install_prefix}
mitkFunctionGetLibrarySearchPaths(search_path, intermediate_dir)
MITK_INSTALL_HELPER_APP()