2 # MITK specific install macro
4 # On Mac everything is installed for each bundle listed in MACOSX_BUNDLE_NAMES
5 # by replacing the DESTINATION parameter. Everything else is passed to the CMake INSTALL command
7 # Usage: MITK_INSTALL( )
13 set(install_directories
"")
14 list(FIND ARGS DESTINATION _destination_index)
15 # set(_install_DESTINATION "")
16 if(_destination_index GREATER -1)
17 message(SEND_ERROR
"MITK_INSTALL macro must not be called with a DESTINATION parameter.")
18 ### This code was a try to replace a given DESTINATION
19 #math(EXPR _destination_index ${_destination_index} + 1)
20 #list(GET ARGS ${_destination_index} _install_DESTINATION)
21 #string(REGEX REPLACE ^bin "" _install_DESTINATION ${_install_DESTINATION})
23 if(NOT MACOSX_BUNDLE_NAMES)
24 install(${ARGS} DESTINATION bin)
26 foreach(bundle_name ${MACOSX_BUNDLE_NAMES})
27 install(${ARGS} DESTINATION ${bundle_name}.app/Contents/MacOS/${_install_DESTINATION})
34 # Fix _target_location
35 # This is used in several install macros
38 if(NOT intermediate_dir)
39 if(WIN32 AND NOT MINGW)
40 set(intermediate_dir Release)
42 set(intermediate_dir .)
48 set(_python_search_paths)
53 mitkFunctionGetLibrarySearchPaths(_search_paths ${intermediate_dir})
57 set(_bundle_dest_dir \
"${_bundle_dest_dir}\")
59 set(_bin_path \"\${CMAKE_INSTALL_PREFIX}/\${_bundle_dest_dir}\")
61 set(_bin_path \"\${CMAKE_INSTALL_PREFIX}/bin\")
64 macro(gp_item_default_embedded_path_override item default_embedded_path_var)
65 get_filename_component(_item_name \"\${item}\" NAME)
66 get_filename_component(_item_path \"\${item}\" PATH)
68 # We have to fix all path references to build trees for plugins
70 if(NOT _item_path MATCHES \"\${CMAKE_INSTALL_PREFIX}/${_bundle_dest_dir}\")
71 # item with relative path or embedded path pointing to some build dir
72 set(full_path \"full_path-NOTFOUND\")
73 file(GLOB_RECURSE full_path \${CMAKE_INSTALL_PREFIX}/${_bundle_dest_dir}/\${_item_name} )
74 list(LENGTH full_path full_path_length)
75 if(full_path_length GREATER 1)
76 list(GET full_path 0 full_path)
78 get_filename_component(_item_path \"\${full_path}\" PATH)
81 set(_plugins_path \"\${_bin_path}/plugins\")
83 if(_item_path STREQUAL _plugins_path
84 OR (_item_path MATCHES \"\${_plugins_path}/\" AND _item_name MATCHES \"liborg\") # this is for legacy BlueBerry bundle support
87 message(\"override: \${item}\")
88 message(\"found file: \${_item_path}/\${_item_name}\")
91 \${CMAKE_INSTALL_PREFIX}/${_bundle_dest_dir}
92 @executable_path \${default_embedded_path_var} \"\${_item_path}\" )
94 set(\${default_embedded_path_var} \"\${_item_path}\")
96 message(\"override result: \${\${default_embedded_path_var}}\")
98 endmacro(gp_item_default_embedded_path_override)
100 macro(gp_resolved_file_type_override file type)
102 get_filename_component(_file_path \"\${file}\" PATH)
103 get_filename_component(_file_name \"\${file}\" NAME)
104 if(_file_path MATCHES \"^\${CMAKE_INSTALL_PREFIX}\")
105 set(\${type} \"local\")
107 if(_file_name MATCHES gdiplus)
108 set(\${type} \"system\")
109 endif(_file_name MATCHES gdiplus)
112 if(file MATCHES \"BluetoothApis.dll\")
113 set(\${type} \"system\" )
116 endmacro(gp_resolved_file_type_override)
119 macro(gp_resolve_item_override context item exepath dirs resolved_item_var resolved_var)
120 if(\${item} MATCHES \"blueberry_core_runtime\")
121 get_filename_component(_item_name \${item} NAME)
122 set(\${resolved_item_var} \"\${exepath}/plugins/\${_item_name}\")
123 set(\${resolved_var} 1)
128 if(\"${_install_GLOB_PLUGINS}\" STREQUAL \"TRUE\")
129 set(GLOBBED_PLUGINS )
130 set(_bb_runtime_lib \"\${_bin_path}/liborg_blueberry_core_runtime${CMAKE_SHARED_LIBRARY_SUFFIX}\")
131 if(EXISTS \"\${_bb_runtime_lib}\")
132 list(APPEND GLOBBED_PLUGINS \"\${_bb_runtime_lib}\")
135 # Iterate over all sub-directories which contain plug-ins
136 # (BlueBerry plug-ins, Qt plug-ins, and auto-load modules)
137 file(GLOB _children \"\${_bin_path}/*\")
138 foreach(_child \${_children})
139 if(IS_DIRECTORY \${_child})
142 file(GLOB_RECURSE _plugins \"\${_child}/*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
144 list(APPEND GLOBBED_PLUGINS \${_plugins})
146 # Now glob for all modules which might have a different extensions.
147 # E.g. on MacOS plugins could have a .dylib extension as well as a .so extension
148 if(NOT \"${CMAKE_SHARED_MODULE_SUFFIX}\" STREQUAL \"\" AND NOT \"${CMAKE_SHARED_MODULE_SUFFIX}\" STREQUAL \"${CMAKE_SHARED_LIBRARY_SUFFIX}\")
149 file(GLOB_RECURSE _modules \"\${_child}/*${CMAKE_SHARED_MODULE_SUFFIX}\")
152 list(APPEND GLOBBED_PLUGINS \${_modules})
159 foreach(_plugin ${_install_PLUGINS} \${GLOBBED_PLUGINS})
160 get_filename_component(_plugin_realpath \${_plugin} REALPATH)
161 list(APPEND PLUGINS \${_plugin_realpath})
164 foreach(_py_lib ${_python_libs})
165 list(APPEND PLUGINS \"\${_bin_path}/\${_py_lib}\")
169 list(REMOVE_DUPLICATES PLUGINS)
171 message(\"globbed plugins: \${PLUGINS}\")
173 set(CMAKE_MODULE_PATH ${MITK_SOURCE_DIR}/CMake ${CMAKE_MODULE_PATH} )
175 set(DIRS \"${_search_paths}\")
177 set(_additional_search_paths ${_install_LIBRARY_DIRS})
178 if(_additional_search_paths)
179 set(DIRS \"\${DIRS};\${_additional_search_paths}\")
181 if(_python_search_paths)
182 set(DIRS \"\${DIRS};\${_python_search_paths}\")
184 foreach(_plugin \${PLUGINS})
185 get_filename_component(_pluginpath \${_plugin} PATH)
186 list(APPEND DIRS \"\${_pluginpath}\")
189 list(REMOVE_DUPLICATES DIRS)
191 # use custom version of BundleUtilities
192 include(BundleUtilities)
194 fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/${_target_location}\" \"\${PLUGINS}\" \"\${DIRS}\")
mitkFunctionInstallPython(_python_libs_out, _search_path_out, _app_bundle)