Fixed bundle with Qt6

This commit is contained in:
matlabbe
2023-03-16 23:07:13 -07:00
parent e7bea0ec03
commit 46edd15121
+33 -17
View File
@@ -121,16 +121,23 @@ IF(BUILD_AS_BUNDLE AND (APPLE OR WIN32))
ENDIF(WIN32 AND CUDA_FOUND) ENDIF(WIN32 AND CUDA_FOUND)
ENDIF(Torch_FOUND) ENDIF(Torch_FOUND)
# Install needed Qt plugins by copying directories from the qt installation IF(Qt6_FOUND)
# One can cull what gets copied by using 'REGEX "..." EXCLUDE' # Reference: https://doc-snapshots.qt.io/qt6-6.4/qt-deploy-runtime-dependencies.html
# Exclude debug libraries # The following script must only be executed at install time
IF(QT_PLUGINS_DIR) set(deploy_script "${CMAKE_CURRENT_BINARY_DIR}/deploy_app$<CONFIG>.cmake")
INSTALL(DIRECTORY "${QT_PLUGINS_DIR}/imageformats" file(GENERATE OUTPUT ${deploy_script} CONTENT "
DESTINATION ${plugin_dest_dir}/plugins # Including the file pointed to by QT_DEPLOY_SUPPORT ensures the generated
COMPONENT runtime # deployment script has access to qt_deploy_runtime_dependencies()
REGEX ".*d4.dll" EXCLUDE include(\"${QT_DEPLOY_SUPPORT}\")
REGEX ".*d4.a" EXCLUDE) qt_deploy_runtime_dependencies(
ELSE() EXECUTABLE \"${APPS}\"
VERBOSE
PLUGINS_DIR ${plugin_dest_dir}/plugins
)")
install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/deploy_appRelease.cmake"
CONFIGURATIONS Release
COMPONENT runtime)
ELSEIF(Qt5_FOUND)
#Qt5 #Qt5
foreach(plugin ${Qt5Gui_PLUGINS}) foreach(plugin ${Qt5Gui_PLUGINS})
get_target_property(plugin_loc ${plugin} LOCATION) get_target_property(plugin_loc ${plugin} LOCATION)
@@ -142,8 +149,8 @@ IF(BUILD_AS_BUNDLE AND (APPLE OR WIN32))
ENDIF(NOT plugin_root) ENDIF(NOT plugin_root)
#MESSAGE(STATUS "Qt5 plugin \"${plugin_loc}\" installed in \"${plugin_dest_dir}/plugins${plugin_type}\"") #MESSAGE(STATUS "Qt5 plugin \"${plugin_loc}\" installed in \"${plugin_dest_dir}/plugins${plugin_type}\"")
INSTALL(FILES ${plugin_loc} INSTALL(FILES ${plugin_loc}
DESTINATION ${plugin_dest_dir}/plugins${plugin_type} DESTINATION ${plugin_dest_dir}/plugins${plugin_type}
COMPONENT runtime) COMPONENT runtime)
endforeach() endforeach()
IF(NOT Qt5Widgets_VERSION VERSION_LESS 5.10.0) IF(NOT Qt5Widgets_VERSION VERSION_LESS 5.10.0)
IF(WIN32) IF(WIN32)
@@ -161,18 +168,27 @@ IF(BUILD_AS_BUNDLE AND (APPLE OR WIN32))
#MESSAGE(STATUS "Qt5 plugin \"${plugin_loc}\" installed in \"${plugin_dest_dir}/plugins${plugin_type}\"") #MESSAGE(STATUS "Qt5 plugin \"${plugin_loc}\" installed in \"${plugin_dest_dir}/plugins${plugin_type}\"")
ENDIF(EXISTS ${plugin_loc}) ENDIF(EXISTS ${plugin_loc})
ENDIF(NOT Qt5Widgets_VERSION VERSION_LESS 5.10.0) ENDIF(NOT Qt5Widgets_VERSION VERSION_LESS 5.10.0)
ELSEIF(QT_PLUGINS_DIR) # Qt4
# Install needed Qt plugins by copying directories from the qt installation
# One can cull what gets copied by using 'REGEX "..." EXCLUDE'
# Exclude debug libraries
INSTALL(DIRECTORY "${QT_PLUGINS_DIR}/imageformats"
DESTINATION ${plugin_dest_dir}/plugins
COMPONENT runtime
REGEX ".*d4.dll" EXCLUDE
REGEX ".*d4.a" EXCLUDE)
ENDIF() ENDIF()
# install a qt.conf file # install a qt.conf file
# this inserts some cmake code into the install script to write the file # this inserts some cmake code into the install script to write the file
SET(QT_CONF_FILE [Paths]\nPlugins=plugins) SET(QT_CONF_FILE [Paths]\nPlugins=plugins)
IF(APPLE) IF(APPLE)
SET(QT_CONF_FILE [Paths]\nPlugins=MacOS/plugins) SET(QT_CONF_FILE [Paths]\nPlugins=MacOS/plugins)
ENDIF(APPLE) ENDIF(APPLE)
INSTALL(CODE " INSTALL(CODE "
file(WRITE \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"${QT_CONF_FILE}\") file(WRITE \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"${QT_CONF_FILE}\")
" COMPONENT runtime) " COMPONENT runtime)
# directories to look for dependencies # directories to look for dependencies
SET(DIRS ${QT_LIBRARY_DIRS} ${PROJECT_SOURCE_DIR}/bin) SET(DIRS ${QT_LIBRARY_DIRS} ${PROJECT_SOURCE_DIR}/bin)
IF(APPLE) IF(APPLE)