Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkMacroInstallHelperApp.cmake
Go to the documentation of this file.
1 #! MITK specific cross plattform install macro
2 #!
3 #! Usage: MITK_INSTALL_HELPER_APP(target1 [target2] ....)
4 #!
6  cmake_parse_arguments(_install "GLOB_PLUGINS" "" "TARGETS;EXECUTABLES;PLUGINS;LIBRARY_DIRS" ${ARGN})
7  list(APPEND _install_TARGETS ${_install_DEFAULT_ARGS})
8 
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)
14  endif()
15 
16  mitkFunctionGetLibrarySearchPaths(DIRS ${intermediate_dir})
17 
18  if(APPLE)
19  list(APPEND DIRS "/usr/lib")
20  endif(APPLE)
21 
22  if(QT_LIBRARY_DIR MATCHES "^(/lib|/lib32|/lib64|/usr/lib|/usr/lib32|/usr/lib64|/usr/X11R6)(/.*)?$")
23  set(_qt_is_system_qt 1)
24  endif()
25 
26  foreach(_target ${_install_EXECUTABLES})
27 
28  set(_qt_plugins_install_dirs "")
29  set(_qt_conf_install_dirs "")
30  set(_target_locations "")
31 
32  get_filename_component(_target_name ${_target} NAME)
33 
34  if(APPLE)
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)
40  else()
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)
46 
47  install(PROGRAMS ${_target} DESTINATION ${bundle_name}.app/Contents/MacOS/)
48  endforeach()
49  endif(NOT MACOSX_BUNDLE_NAMES)
50  else()
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}\")")
60  endif()
61  endif()
62 
63  foreach(_target_location ${_target_locations})
64  if(NOT _qt_is_system_qt)
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  endif()
87  endif()
89  endforeach(_target_location)
90 
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 .)
96  if(APPLE)
97  set(_qt_conf_plugin_install_prefix ./MacOS)
98  endif()
99  foreach(_qt_conf_install_dir ${_qt_conf_install_dirs})
100  install(CODE "file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${_qt_conf_install_dir}/qt.conf\" \"
101 [Paths]
102 Prefix=${_qt_conf_plugin_install_prefix}
103 \")")
104  endforeach()
105  endif()
106 
107  endforeach()
108 
109 endmacro(MITK_INSTALL_HELPER_APP)
_fixup_target()
mitkFunctionGetLibrarySearchPaths(search_path, intermediate_dir)
MITK_INSTALL_HELPER_APP()
const std::string NAME