Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
mitkFunctionInstallAutoLoadModules.cmake
Go to the documentation of this file.
1 
2 #! \brief Install auto-load modules needed by plug-ins.
3 #!
4 #! Uses the MITK_AUTOLOAD_TARGETS target property of the plug-in
5 #! targets to extract a list of auto-load target names which will
6 #! be installed in the given <code>DESTINATION</code> with an appropriate
7 #! sub-directory appended. If an entry in <code>TARGETS</code>
8 #! is not a known target, a warning will be issued. This macro
9 #! can also work on imported plug-in targets.
10 #!
11 #! \note This macro is usually not called directly. It is indirectly
12 #! called by a call to FunctionCreateBlueBerryApplication().
13 #!
14 #! \param PLUGINS A list of plug-in targets from which installable audo-load modules are derived.
15 #! \param DESTINATION The install destination, e.g. "bin".
17 
18  cmake_parse_arguments(_INSTALL "" "DESTINATION" "PLUGINS" ${ARGN})
19 
20  if(NOT _INSTALL_PLUGINS)
21  message(SEND_ERROR "PLUGINS argument is required")
22  endif()
23 
24  if(NOT _INSTALL_DESTINATION)
25  message(SEND_ERROR "DESTINATION argument is required")
26  endif()
27 
28  foreach(_install_plugin ${_INSTALL_PLUGINS})
29  if(TARGET ${_install_plugin})
30  get_target_property(_autoload_targets ${_install_plugin} MITK_AUTOLOAD_TARGETS)
31  if (_autoload_targets)
32  foreach(_autoload_target ${_autoload_targets})
33  get_target_property(_autoload_subdir ${_autoload_target} MITK_AUTOLOAD_DIRECTORY)
34  if(NOT _autoload_subdir)
35  message(WARNING "Target ${_autoload_target} does not seem to be an auto-load module. Skipping installation.")
36  else(NOT _${_autoload_target}_installed)
37 
38  set(_module_install_dir ${_INSTALL_DESTINATION}/${_autoload_subdir})
39 
40  get_target_property(_is_imported ${_autoload_target} IMPORTED)
41  if(_is_imported)
42  get_target_property(_target_loc_debug ${_autoload_target} IMPORTED_LOCATION_DEBUG)
43  get_target_property(_target_loc_release ${_autoload_target} IMPORTED_LOCATION_RELEASE)
44  else()
45  # Since we need to use install(FILE ...) we need to get the absolute path to the
46  # module. This is a bit tricky and we only support Debug and Release configurations
47  # on multi-configuration build systems.
48  if(WIN32)
49  get_target_property(_target_loc_debug ${_autoload_target} RUNTIME_OUTPUT_DIRECTORY)
50  else()
51  get_target_property(_target_loc_debug ${_autoload_target} LIBRARY_OUTPUT_DIRECTORY)
52  endif()
53  set(_target_loc_release ${_target_loc_debug})
54  if(NOT CMAKE_CFG_INTDIR STREQUAL ".")
55  set(_target_loc_debug "${_target_loc_debug}/Debug")
56  set(_target_loc_release "${_target_loc_release}/Release")
57  endif()
58  set(_target_loc_debug ${_target_loc_debug}/${CMAKE_SHARED_LIBRARY_PREFIX}${_autoload_target}${CMAKE_SHARED_LIBRARY_SUFFIX})
59  set(_target_loc_release ${_target_loc_release}/${CMAKE_SHARED_LIBRARY_PREFIX}${_autoload_target}${CMAKE_SHARED_LIBRARY_SUFFIX})
60  endif()
61 
62  get_filename_component(_target_filename_debug "${_target_loc_debug}" NAME)
63  get_filename_component(_target_filename_release "${_target_loc_release}" NAME)
64  install(FILES ${_target_loc_debug}
65  DESTINATION ${_module_install_dir}
66  CONFIGURATIONS Debug)
67  install(FILES ${_target_loc_release}
68  DESTINATION ${_module_install_dir}
69  CONFIGURATIONS Release)
70 
71  set(_${_autoload_target}_installed 1)
72 
73  if(UNIX AND NOT APPLE)
74  if(_target_filename_debug)
75  install(CODE "file(RPATH_REMOVE
76  FILE \"\${CMAKE_INSTALL_PREFIX}/${_module_install_dir}/${_target_filename_debug}\")")
77  endif()
78  if(_target_filename_release)
79  install(CODE "file(RPATH_REMOVE
80  FILE \"\${CMAKE_INSTALL_PREFIX}/${_module_install_dir}/${_target_filename_release}\")")
81  endif()
82  endif()
83  endif()
84  endforeach()
85  endif()
86  else()
87  message(WARNING "Ignoring unknown target \"${_install_plugin}\" for installation.")
88  endif()
89  endforeach()
90 
91 endfunction()
92 
94 
95  cmake_parse_arguments(_INSTALL "" "APP_NAME" "PLUGINS" ${ARGN})
96 
97  set(_destination bin)
98  if(APPLE)
99  set(_destination ${_INSTALL_APP_NAME}.app/Contents/MacOS)
100  endif()
101 
103  PLUGINS ${_INSTALL_PLUGINS}
104  DESTINATION ${_destination}
105  )
106 
107 endfunction()
static const unsigned int unknown
Unknown size marker.
Definition: jsoncpp.cpp:1583
mitkFunctionInstallAutoLoadModules()
Install auto-load modules needed by plug-ins.
BlueBerryApplicationInstallHook()
const std::string TARGET