diff --git a/CMake/mitkMacroInstall.cmake b/CMake/mitkMacroInstall.cmake index 74b3198b21..cf6a93af20 100644 --- a/CMake/mitkMacroInstall.cmake +++ b/CMake/mitkMacroInstall.cmake @@ -1,192 +1,192 @@ # # MITK specific install macro # # On Mac everything is installed for each bundle listed in MACOSX_BUNDLE_NAMES # by replacing the DESTINATION parameter. Everything else is passed to the CMake INSTALL command # # Usage: MITK_INSTALL( ) # macro(MITK_INSTALL) set(ARGS ${ARGN}) set(install_directories "") list(FIND ARGS DESTINATION _destination_index) # set(_install_DESTINATION "") if(_destination_index GREATER -1) message(SEND_ERROR "MITK_INSTALL macro must not be called with a DESTINATION parameter.") ### This code was a try to replace a given DESTINATION #math(EXPR _destination_index ${_destination_index} + 1) #list(GET ARGS ${_destination_index} _install_DESTINATION) #string(REGEX REPLACE ^bin "" _install_DESTINATION ${_install_DESTINATION}) else() if(NOT MACOSX_BUNDLE_NAMES) install(${ARGS} DESTINATION bin) else() foreach(bundle_name ${MACOSX_BUNDLE_NAMES}) install(${ARGS} DESTINATION ${bundle_name}.app/Contents/MacOS/${_install_DESTINATION}) endforeach() endif() endif() endmacro() # Fix _target_location # This is used in several install macros macro(_fixup_target) if(NOT intermediate_dir) if(WIN32 AND NOT MINGW) set(intermediate_dir Release) else() set(intermediate_dir .) endif() endif() set(_python_libs ) set(_python_dirs ) if(MITK_USE_Python) include(mitkMacroInstallPython) MITK_INSTALL_PYTHON(_python_libs _python_dirs) endif() mitkFunctionGetLibrarySearchPaths(_search_paths ${intermediate_dir}) install(CODE " set(_bundle_dest_dir \"${_bundle_dest_dir}\") if(_bundle_dest_dir) set(_bin_path \"\${CMAKE_INSTALL_PREFIX}/\${_bundle_dest_dir}\") else() set(_bin_path \"\${CMAKE_INSTALL_PREFIX}/bin\") endif() macro(gp_item_default_embedded_path_override item default_embedded_path_var) get_filename_component(_item_name \"\${item}\" NAME) get_filename_component(_item_path \"\${item}\" PATH) # We have to fix all path references to build trees for plugins if(NOT _item_path MATCHES \"\${CMAKE_INSTALL_PREFIX}/${_bundle_dest_dir}\") # item with relative path or embedded path pointing to some build dir set(full_path \"full_path-NOTFOUND\") file(GLOB_RECURSE full_path \${CMAKE_INSTALL_PREFIX}/${_bundle_dest_dir}/\${_item_name} ) list(LENGTH full_path full_path_length) if(full_path_length GREATER 1) list(GET full_path 0 full_path) endif() get_filename_component(_item_path \"\${full_path}\" PATH) endif() set(_plugins_path \"\${_bin_path}/plugins\") if(_item_path STREQUAL _plugins_path OR (_item_path MATCHES \"\${_plugins_path}/\" AND _item_name MATCHES \"liborg\") # this is for legacy BlueBerry bundle support ) # Only fix plugins message(\"override: \${item}\") message(\"found file: \${_item_path}/\${_item_name}\") if(APPLE) string(REPLACE \${CMAKE_INSTALL_PREFIX}/${_bundle_dest_dir} @executable_path \${default_embedded_path_var} \"\${_item_path}\" ) else() set(\${default_embedded_path_var} \"\${_item_path}\") endif() message(\"override result: \${\${default_embedded_path_var}}\") endif() endmacro(gp_item_default_embedded_path_override) macro(gp_resolved_file_type_override file type) if(NOT APPLE) get_filename_component(_file_path \"\${file}\" PATH) get_filename_component(_file_name \"\${file}\" NAME) if(_file_path MATCHES \"^\${CMAKE_INSTALL_PREFIX}\") set(\${type} \"local\") endif() if(_file_name MATCHES gdiplus) set(\${type} \"system\") endif(_file_name MATCHES gdiplus) endif() endmacro(gp_resolved_file_type_override) if(NOT APPLE) macro(gp_resolve_item_override context item exepath dirs resolved_item_var resolved_var) if(\${item} MATCHES \"blueberry_osgi\") get_filename_component(_item_name \${item} NAME) set(\${resolved_item_var} \"\${exepath}/plugins/\${_item_name}\") set(\${resolved_var} 1) endif() endmacro() endif() if(\"${_install_GLOB_PLUGINS}\" STREQUAL \"TRUE\") set(GLOBBED_PLUGINS ) set(_bb_osgi_lib \"\${_bin_path}/liborg_blueberry_osgi${CMAKE_SHARED_LIBRARY_SUFFIX}\") if(EXISTS \"\${_bb_osgi_lib}\") list(APPEND GLOBBED_PLUGINS \"\${_bb_osgi_lib}\") endif() # Iterate over all sub-directories which contain plug-ins # (BlueBerry plug-ins, Qt plug-ins, and auto-load modules) file(GLOB _children \"\${_bin_path}/*\") foreach(_child \${_children}) if(IS_DIRECTORY \${_child}) set(_plugins ) set(_modules ) file(GLOB_RECURSE _plugins \"\${_child}/*${CMAKE_SHARED_LIBRARY_SUFFIX}\") if(_plugins) list(APPEND GLOBBED_PLUGINS \${_plugins}) endif() # Now glob for all modules which might have a different extensions. # E.g. on MacOS plugins could have a .dylib extension as well as a .so extension if(NOT \"${CMAKE_SHARED_MODULE_SUFFIX}\" STREQUAL \"\" AND NOT \"${CMAKE_SHARED_MODULE_SUFFIX}\" STREQUAL \"${CMAKE_SHARED_LIBRARY_SUFFIX}\") file(GLOB_RECURSE _modules \"\${_child}/*${CMAKE_SHARED_MODULE_SUFFIX}\") endif() if(_modules) list(APPEND GLOBBED_PLUGINS \${_modules}) endif() endif() endforeach() endif() set(PLUGINS ) foreach(_plugin ${_install_PLUGINS} \${GLOBBED_PLUGINS}) get_filename_component(_plugin_realpath \${_plugin} REALPATH) list(APPEND PLUGINS \${_plugin_realpath}) endforeach() foreach(_py_lib ${_python_libs}) - list(APPEND PLUGINS \"\${CMAKE_INSTALL_PREFIX}/bin/\${_py_lib}\") + list(APPEND PLUGINS \"\${_bin_path}/\${_py_lib}\") endforeach() if(PLUGINS) list(REMOVE_DUPLICATES PLUGINS) endif(PLUGINS) message(\"globbed plugins: \${PLUGINS}\") set(CMAKE_MODULE_PATH ${MITK_SOURCE_DIR}/CMake ${CMAKE_MODULE_PATH} ) set(DIRS \"${_search_paths}\") set(_additional_search_paths ${_install_LIBRARY_DIRS}) if(_additional_search_paths) set(DIRS \"\${DIRS};\${_additional_search_paths}\") endif() foreach(_plugin \${PLUGINS}) get_filename_component(_pluginpath \${_plugin} PATH) list(APPEND DIRS \"\${_pluginpath}\") endforeach(_plugin) foreach(_dir ${_python_dirs}) list(APPEND DIRS \"\${_dir}\") endforeach() list(REMOVE_DUPLICATES DIRS) # use custom version of BundleUtilities include(BundleUtilities) fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/${_target_location}\" \"\${PLUGINS}\" \"\${DIRS}\") ") endmacro() diff --git a/CMake/mitkMacroInstallPython.cmake b/CMake/mitkMacroInstallPython.cmake index 051bc27a4e..fee50a3146 100644 --- a/CMake/mitkMacroInstallPython.cmake +++ b/CMake/mitkMacroInstallPython.cmake @@ -1,140 +1,138 @@ macro(MITK_INSTALL_PYTHON _python_libs _python_dirs) - MESSAGE("==================================") - MESSAGE("APPNAME: " ${_INSTALL_APP_NAME}) - MESSAGE("==================================") set(_destination bin) if(APPLE) - set(_destination ${_INSTALL_APP_NAME}.app/Contents/MacOS) + set(_destination MitkWorkbench.app/Contents/MacOS) endif() if(UNIX) # apple and linux only supports .so as loadable extension set(PYTHON_LIB_SUFFIX .so) else(WIN32) # windows only supports pyd as loadable extension set(PYTHON_LIB_SUFFIX .pyd) endif() # SimpleITK if(MITK_USE_SimpleITK) install(FILES "${SimpleITK_DIR}/Wrapping/SimpleITK.py" DESTINATION ${_destination}/Python/SimpleITK ) install(FILES "${SimpleITK_DIR}/Wrapping/__init__.py" DESTINATION ${_destination}/Python/SimpleITK ) install(FILES "${SimpleITK_DIR}/Wrapping/_SimpleITK${PYTHON_LIB_SUFFIX}" DESTINATION ${_destination}/Python/SimpleITK ) if(UNIX AND NOT APPLE) install(CODE "file(RPATH_REMOVE FILE \"\${CMAKE_INSTALL_PREFIX}/bin/Python/SimpleITK/_SimpleITK${PYTHON_LIB_SUFFIX}\")") endif() list(APPEND _python_libs "Python/SimpleITK/_SimpleITK${PYTHON_LIB_SUFFIX}") list(APPEND _python_dirs "${SimpleITK_DIR}/lib") endif() # install OpenCV python wrapping if(MITK_USE_OpenCV) - list(APPEND _python_libs "cv2${CMAKE_SHARED_LIBRARY_SUFFIX}") + list(APPEND _python_libs "cv2${PYTHON_LIB_SUFFIX}") if(UNIX) install(FILES "${OpenCV_DIR}/lib/cv2${PYTHON_LIB_SUFFIX}" DESTINATION ${_destination}) else() install(FILES "${OpenCV_DIR}/lib/Release/cv2${PYTHON_LIB_SUFFIX}" DESTINATION ${_destination}) endif() if(UNIX AND NOT APPLE) install(CODE "file(RPATH_REMOVE FILE \"\${CMAKE_INSTALL_PREFIX}/bin/cv2${CMAKE_SHARED_LIBRARY_SUFFIX}\")") endif() list(APPEND _python_dirs "${OpenCV_DIR}/lib") endif() # install VTK python wrapping find_package(VTK REQUIRED) set(_VTK_PYTHON_TARGETS ) # find all vtk python wrapped targets foreach(_lib ${VTK_LIBRARIES}) # exclude system libs if(${_lib} MATCHES "^vtk.+") # use only python wrapped modules ( targets end with PythonD ) if(TARGET ${_lib}PythonD) list(APPEND _VTK_PYTHON_TARGETS ${_lib}Python) endif() endif() endforeach() # install the python modules and loaders foreach(_target ${_VTK_PYTHON_TARGETS}) # get the properties of the python wrapped target if( CMAKE_BUILD_TYPE STREQUAL "Debug") get_target_property(_target_lib "${_target}D" IMPORTED_LOCATION_DEBUG) else() get_target_property(_target_lib "${_target}D" IMPORTED_LOCATION_RELEASE) endif() get_filename_component(_filepath "${_target_lib}" PATH) install(FILES "${_filepath}/${_target}${PYTHON_LIB_SUFFIX}" DESTINATION ${_destination}) if(UNIX AND NOT APPLE ) install(CODE "file(RPATH_REMOVE FILE \"\${CMAKE_INSTALL_PREFIX}/bin/${_target}${PYTHON_LIB_SUFFIX}\")") endif() list(APPEND _python_libs "${_target}${PYTHON_LIB_SUFFIX}") endforeach() # install vtk python. This folder contains all *.py files for VTK module loading. # glob through all files, NSIS can't use directories file(GLOB_RECURSE item RELATIVE "${VTK_DIR}/Wrapping/Python/vtk" "${VTK_DIR}/Wrapping/Python/vtk/*.py") foreach(f ${item}) get_filename_component(_filepath "${f}" PATH) install(FILES "${VTK_DIR}/Wrapping/Python/vtk/${f}" DESTINATION ${_destination}/Python/vtk/${_filepath}) endforeach() list(APPEND _python_dirs "${VTK_DIR}/lib") # install the python runtime from the superbuild if(NOT MITK_USE_SYSTEM_PYTHON) + #TODO: handle APPLE runtime is missing if(UNIX) list(APPEND _python_dirs "${Python_DIR}/lib") # install python stuff install(DIRECTORY "${Python_DIR}/lib/python${PYTHON_MAJOR_VERSION}.${PYTHON_MINOR_VERSION}" DESTINATION ${_destination}/Python/lib USE_SOURCE_PERMISSIONS COMPONENT Runtime) install(FILES "${Python_DIR}/include/python${PYTHON_MAJOR_VERSION}.${PYTHON_MINOR_VERSION}/pyconfig.h" DESTINATION ${_destination}/Python/include/python${PYTHON_MAJOR_VERSION}.${PYTHON_MINOR_VERSION}) else() list(APPEND _python_dirs "${Python_DIR}/libs") list(APPEND _python_dirs "${Python_DIR}/bin") file(GLOB_RECURSE item RELATIVE "${Python_DIR}/Lib" "${Python_DIR}/Lib/*") foreach(f ${item}) get_filename_component(_filepath "${f}" PATH) install(FILES "${Python_DIR}/Lib/${f}" DESTINATION bin/Python/Lib/${_filepath}) endforeach() file(GLOB_RECURSE item RELATIVE "${Python_DIR}/include" "${Python_DIR}/include/*") foreach(f ${item}) get_filename_component(_filepath "${f}" PATH) install(FILES "${Python_DIR}/include/${f}" DESTINATION bin/Python/include/${_filepath}) endforeach() endif() endif() if(Numpy_DIR) # glob through all files, NSIS can't use directories file(GLOB_RECURSE item RELATIVE "${Numpy_DIR}/numpy" "${Numpy_DIR}/numpy/*") foreach(f ${item}) get_filename_component(_filepath "${f}" PATH) install(FILES "${Numpy_DIR}/numpy/${f}" DESTINATION ${_destination}/Python/numpy/${_filepath}) endforeach() endif() list(REMOVE_DUPLICATES _python_dirs) endmacro()