Medical Imaging Interaction Toolkit  2018.4.99-b20efe7f
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)
14  set(intermediate_dir Release)
15  endif()
16 
17  foreach(_target ${_install_EXECUTABLES})
18  get_target_property(_is_bundle ${_target} MACOSX_BUNDLE)
19 
20  set(_qt_conf_install_dirs "")
21  set(_target_locations "")
22 
23  if(APPLE)
24  if(_is_bundle)
25  set(_target_locations ${_target}.app)
26  set(${_target_locations}_qt_plugins_install_dir ${_target}.app/Contents/MacOS)
27  set(_bundle_dest_dir ${_target}.app/Contents/MacOS)
28  set(_qt_conf_install_dirs ${_target}.app/Contents/Resources)
29  install(TARGETS ${_target} BUNDLE DESTINATION . )
30  else()
31  if(NOT MACOSX_BUNDLE_NAMES)
32  set(_qt_conf_install_dirs bin)
33  set(_target_locations bin/${_target})
34  install(TARGETS ${_target} RUNTIME DESTINATION bin)
35  else()
36  foreach(bundle_name ${MACOSX_BUNDLE_NAMES})
37  list(APPEND _qt_conf_install_dirs ${bundle_name}.app/Contents/Resources)
38  set(_current_target_location ${bundle_name}.app/Contents/MacOS/${_target})
39  list(APPEND _target_locations ${_current_target_location})
40  install(TARGETS ${_target} RUNTIME DESTINATION ${bundle_name}.app/Contents/MacOS/)
41  endforeach()
42  endif()
43  endif()
44  else()
45  set(_target_locations bin/${_target}${CMAKE_EXECUTABLE_SUFFIX})
46  set(_qt_conf_install_dirs bin)
47  install(TARGETS ${_target} RUNTIME DESTINATION bin)
48  endif()
49 
50  foreach(_target_location ${_target_locations})
52  endforeach()
53 
54  #--------------------------------------------------------------------------------
55  # install a qt.conf file
56  # this inserts some cmake code into the install script to write the file
57  if(MITK_USE_Qt5)
58  set(_qt_conf_plugin_install_prefix .)
59  if(APPLE)
60  set(_qt_conf_plugin_install_prefix ./MacOS)
61  endif()
62 
63  foreach(_qt_conf_install_dir ${_qt_conf_install_dirs})
64  install(CODE "file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${_qt_conf_install_dir}/qt.conf\" \"
65  [Paths]
66  Prefix=${_qt_conf_plugin_install_prefix}
67  \")")
68  endforeach()
69  endif()
70  endforeach()
71 endmacro()
_fixup_target()
MITK_INSTALL_TARGETS()