mirror of
https://github.com/introlab/rtabmap.git
synced 2026-10-04 00:57:46 +08:00
fixing packaging on mac
This commit is contained in:
+66
-12
@@ -24,10 +24,10 @@ IF(WIN32)
|
||||
ELSE( MINGW )
|
||||
SET(SRC_FILES ${SRC_FILES} ${PROJECT_NAME}.rc)
|
||||
ENDIF( MINGW )
|
||||
ENDIF(WIN32)
|
||||
|
||||
IF(BUILD_AS_BUNDLE)
|
||||
ADD_DEFINITIONS("-DBUILD_AS_BUNDLE")
|
||||
ENDIF(WIN32)
|
||||
|
||||
IF(BUILD_AS_BUNDLE)
|
||||
ADD_DEFINITIONS("-DBUILD_AS_BUNDLE")
|
||||
ENDIF()
|
||||
|
||||
# Add binary
|
||||
@@ -70,13 +70,13 @@ IF(BUILD_AS_BUNDLE AND (APPLE OR WIN32))
|
||||
SET(thirdparty_dest_dir bin)
|
||||
|
||||
IF(APPLE)
|
||||
SET(plugin_dest_dir MacOS/plugins)
|
||||
IF(Qt6_FOUND)
|
||||
SET(plugin_dest_dir PlugIns)
|
||||
SET(plugin_dest_dir MacOS/plugins)
|
||||
IF(Qt6_FOUND)
|
||||
SET(plugin_dest_dir PlugIns)
|
||||
ENDIF()
|
||||
SET(qtconf_dest_dir Resources)
|
||||
SET(thirdparty_dest_dir MacOS)
|
||||
SET(APPS "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/MacOS/${CMAKE_BUNDLE_NAME}")
|
||||
SET(APPS "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/MacOS/${CMAKE_BUNDLE_NAME}")
|
||||
ENDIF(APPLE)
|
||||
|
||||
IF(OpenNI2_FOUND)
|
||||
@@ -241,14 +241,49 @@ IF(BUILD_AS_BUNDLE AND (APPLE OR WIN32))
|
||||
ENDIF(WIN32)
|
||||
ENDIF(Python3_FOUND)
|
||||
|
||||
IF(Qt6_FOUND)
|
||||
IF(Qt6_FOUND AND APPLE)
|
||||
# On macOS we do NOT use qt_deploy_runtime_dependencies (macdeployqt):
|
||||
# macdeployqt cannot deploy VTK 9.6+, whose libraries reference each other
|
||||
# via @rpath relative to "@loader_path/../lib". Instead we install the Qt plugins
|
||||
# manually and let fixup_bundle() below deploy all libraries.
|
||||
IF(TARGET Qt6::QCocoaIntegrationPlugin)
|
||||
get_target_property(_qt_plugin_loc Qt6::QCocoaIntegrationPlugin LOCATION)
|
||||
get_filename_component(_qt_plugins_dir "${_qt_plugin_loc}" DIRECTORY) # .../plugins/platforms
|
||||
get_filename_component(_qt_plugins_dir "${_qt_plugins_dir}" DIRECTORY) # .../plugins
|
||||
FOREACH(_qt_plugin_type platforms styles imageformats iconengines)
|
||||
IF(EXISTS "${_qt_plugins_dir}/${_qt_plugin_type}")
|
||||
# Homebrew Qt plugins are symlinks into the Cellar; resolve them to the
|
||||
# real files so they aren't installed as dangling symlinks (which would
|
||||
# break fixup_bundle and codesign).
|
||||
FILE(GLOB _qt_plugin_files "${_qt_plugins_dir}/${_qt_plugin_type}/*${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
||||
SET(_qt_plugin_real "")
|
||||
FOREACH(_qt_plugin_file ${_qt_plugin_files})
|
||||
GET_FILENAME_COMPONENT(_qt_plugin_file "${_qt_plugin_file}" REALPATH)
|
||||
LIST(APPEND _qt_plugin_real "${_qt_plugin_file}")
|
||||
ENDFOREACH()
|
||||
IF(_qt_plugin_real)
|
||||
INSTALL(FILES ${_qt_plugin_real}
|
||||
DESTINATION ${plugin_dest_dir}/${_qt_plugin_type}
|
||||
COMPONENT runtime)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDFOREACH()
|
||||
ELSE()
|
||||
MESSAGE(WARNING "Qt6::QCocoaIntegrationPlugin target not found: Qt plugins may be missing from the bundle")
|
||||
ENDIF()
|
||||
# qt.conf so Qt finds the bundled plugins (path is relative to Contents/)
|
||||
SET(QT_CONF_FILE [Paths]\nPlugins=${plugin_dest_dir})
|
||||
INSTALL(CODE "
|
||||
file(WRITE \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"${QT_CONF_FILE}\")
|
||||
" COMPONENT runtime)
|
||||
ELSEIF(Qt6_FOUND)
|
||||
# Reference: https://doc-snapshots.qt.io/qt6-6.4/qt-deploy-runtime-dependencies.html
|
||||
# The following script must only be executed at install time
|
||||
set(deploy_script "${CMAKE_CURRENT_BINARY_DIR}/deploy_app$<CONFIG>.cmake")
|
||||
file(GENERATE OUTPUT ${deploy_script} CONTENT "
|
||||
# Including the file pointed to by QT_DEPLOY_SUPPORT ensures the generated
|
||||
# deployment script has access to qt_deploy_runtime_dependencies()
|
||||
include(\"${QT_DEPLOY_SUPPORT}\")
|
||||
include(\"${QT_DEPLOY_SUPPORT}\")
|
||||
qt_deploy_runtime_dependencies(
|
||||
EXECUTABLE \"${APPS}\"
|
||||
PLUGINS_DIR ${plugin_dest_dir}
|
||||
@@ -328,7 +363,7 @@ IF(BUILD_AS_BUNDLE AND (APPLE OR WIN32))
|
||||
INSTALL(CODE "
|
||||
file(WRITE \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"${QT_CONF_FILE}\")
|
||||
" COMPONENT runtime)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# directories to look for dependencies
|
||||
SET(DIRS "${QT_LIBRARY_DIRS}" "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/lib")
|
||||
@@ -363,6 +398,25 @@ IF(BUILD_AS_BUNDLE AND (APPLE OR WIN32))
|
||||
include(\"BundleUtilities\")
|
||||
fixup_bundle(\"${APPS}\" \"\${ALL_LIBS}\" \"${DIRS}\")
|
||||
" COMPONENT runtime)
|
||||
|
||||
|
||||
IF(APPLE)
|
||||
# Re-sign ad-hoc AFTER fixup_bundle has finished all its install_name_tool
|
||||
# edits.
|
||||
install(CODE "
|
||||
set(_contents \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}\")
|
||||
get_filename_component(_app \"\${_contents}\" DIRECTORY)
|
||||
file(GLOB_RECURSE _nested \"\${_contents}/*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
|
||||
foreach(_f \${_nested})
|
||||
execute_process(COMMAND codesign --force --sign - --timestamp=none \"\${_f}\")
|
||||
endforeach()
|
||||
file(GLOB _frameworks \"\${_contents}/Frameworks/*.framework\")
|
||||
foreach(_f \${_frameworks})
|
||||
execute_process(COMMAND codesign --force --sign - --timestamp=none \"\${_f}\")
|
||||
endforeach()
|
||||
message(STATUS \"Ad-hoc re-signing bundle: \${_app}\")
|
||||
execute_process(COMMAND codesign --force --sign - --timestamp=none \"\${_app}\")
|
||||
" COMPONENT runtime)
|
||||
ENDIF(APPLE)
|
||||
|
||||
ENDIF(BUILD_AS_BUNDLE AND (APPLE OR WIN32))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user