Medical Imaging Interaction Toolkit  2018.4.99-eed36131
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)
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  foreach(_target ${_install_EXECUTABLES})
23  set(_qt_conf_install_dirs "")
24  set(_target_locations "")
25 
26  get_filename_component(_target_name ${_target} NAME)
27 
28  if(APPLE)
29  if(NOT MACOSX_BUNDLE_NAMES)
30  set(_qt_conf_install_dirs bin)
31  set(_target_locations bin/${_target_name})
32  install(PROGRAMS ${_target} DESTINATION bin)
33  else()
34  foreach(bundle_name ${MACOSX_BUNDLE_NAMES})
35  list(APPEND _qt_conf_install_dirs ${bundle_name}.app/Contents/Resources)
36  set(_current_target_location ${bundle_name}.app/Contents/MacOS/${_target_name})
37  list(APPEND _target_locations ${_current_target_location})
38  install(PROGRAMS ${_target} DESTINATION ${bundle_name}.app/Contents/MacOS/)
39  endforeach()
40  endif(NOT MACOSX_BUNDLE_NAMES)
41  else()
42  set(_target_location bin/${_target_name})
43  set(_qt_conf_install_dirs bin)
44  install(PROGRAMS ${_target} DESTINATION bin)
45  if(UNIX AND NOT WIN32)
46  # Remove the rpath from helper applications. We assume that all dependencies
47  # are installed into the same location as the helper application.
48  install(CODE "file(RPATH_REMOVE
49  FILE \"\${CMAKE_INSTALL_PREFIX}/${_target_location}\")")
50  endif()
51  endif()
52 
53  foreach(_target_location ${_target_locations})
55  endforeach(_target_location)
56 
57  #--------------------------------------------------------------------------------
58  # install a qt.conf file
59  # this inserts some cmake code into the install script to write the file
60  if(MITK_USE_Qt5)
61  set(_qt_conf_plugin_install_prefix .)
62  if(APPLE)
63  set(_qt_conf_plugin_install_prefix ./MacOS)
64  endif()
65  foreach(_qt_conf_install_dir ${_qt_conf_install_dirs})
66  install(CODE "file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${_qt_conf_install_dir}/qt.conf\" \"
67 [Paths]
68 Prefix=${_qt_conf_plugin_install_prefix}
69 \")")
70  endforeach()
71  endif()
72  endforeach()
73 
_fixup_target()
mitkFunctionGetLibrarySearchPaths(search_path, intermediate_dir)
MITK_INSTALL_HELPER_APP()
const std::string NAME