Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkMacroInstallTargets.cmake
Go to the documentation of this file.
1 #
2 # MITK specific cross plattform install macro
3 #
4 # Usage: MITK_INSTALL_TARGETS(target1 [target2] ....)
5 #
7  cmake_parse_arguments(_install "GLOB_PLUGINS" "" "TARGETS;EXECUTABLES;PLUGINS;LIBRARY_DIRS" ${ARGN})
8  list(APPEND _install_TARGETS ${_install_DEFAULT_ARGS})
9 
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)
15  endif()
16 
17  if(QT_LIBRARY_DIR MATCHES "^(/lib|/lib32|/lib64|/usr/lib|/usr/lib32|/usr/lib64|/usr/X11R6)(/.*)?$")
18  set(_qt_is_system_qt 1)
19  endif()
20 
21  foreach(_target ${_install_EXECUTABLES})
22 
23  get_target_property(_is_bundle ${_target} MACOSX_BUNDLE)
24 
25  set(_qt_plugins_install_dirs "")
26  set(_qt_conf_install_dirs "")
27  set(_target_locations "")
28 
29  if(APPLE)
30  if(_is_bundle)
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 . )
37  else()
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)
43  else()
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) ")
50 
51  install(TARGETS ${_target} RUNTIME DESTINATION ${bundle_name}.app/Contents/MacOS/)
52  endforeach()
53  endif()
54  endif()
55  else()
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)
60  endif()
61 
62  foreach(_target_location ${_target_locations})
63  if(NOT _qt_is_system_qt)
64 
65  if(QT_PLUGINS_DIR)
66  if(WIN32)
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}"
71  )
72 
73  install(DIRECTORY "${QT_PLUGINS_DIR}"
74  DESTINATION ${${_target_location}_qt_plugins_install_dir}
75  CONFIGURATIONS Debug
76  FILES_MATCHING REGEX "d4?${CMAKE_SHARED_LIBRARY_SUFFIX}"
77  )
78  else(WIN32)
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}"
83  )
84 
85  endif(WIN32)
86 
87  endif()
88  endif()
90  endforeach()
91 
92  if(NOT _qt_is_system_qt)
93 
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 .)
98  if(APPLE)
99  set(_qt_conf_plugin_install_prefix ./MacOS)
100  endif()
101 
102  foreach(_qt_conf_install_dir ${_qt_conf_install_dirs})
103  install(CODE "file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${_qt_conf_install_dir}/qt.conf\" \"
104 [Paths]
105 Prefix=${_qt_conf_plugin_install_prefix}
106 \")")
107  endforeach()
108 
109  endif()
110 
111  endforeach()
112 
113 endmacro()
_fixup_target()
MITK_INSTALL_TARGETS()