diff options
Diffstat (limited to 'src/corelib/Qt6CoreDeploySupport.cmake')
-rw-r--r-- | src/corelib/Qt6CoreDeploySupport.cmake | 98 |
1 files changed, 69 insertions, 29 deletions
diff --git a/src/corelib/Qt6CoreDeploySupport.cmake b/src/corelib/Qt6CoreDeploySupport.cmake index aeda7405be..2fc8f8bf1c 100644 --- a/src/corelib/Qt6CoreDeploySupport.cmake +++ b/src/corelib/Qt6CoreDeploySupport.cmake @@ -153,6 +153,34 @@ function(_qt_internal_get_rpath_origin out_var) set(${out_var} ${rpath_origin} PARENT_SCOPE) endfunction() +# Add a function to the list of deployment hooks. +# The hooks are run at the end of _qt_internal_generic_deployqt. +# +# Every hook is passed the parameters of _qt_internal_generic_deployqt plus the following: +# RESOLVED_DEPENDENCIES: list of resolved dependencies that were installed. +function(_qt_internal_add_deployment_hook function_name) + set_property(GLOBAL APPEND PROPERTY QT_INTERNAL_DEPLOYMENT_HOOKS "${function_name}") +endfunction() + +# Run all registered deployment hooks. +function(_qt_internal_run_deployment_hooks) + get_property(hooks GLOBAL PROPERTY QT_INTERNAL_DEPLOYMENT_HOOKS) + foreach(hook IN LISTS hooks) + if(NOT COMMAND "${hook}") + message(AUTHOR_WARNING "'${hook}' is not a command but was added as deployment hook.") + continue() + endif() + if(CMAKE_VERSION GREATER_EQUAL "3.19") + cmake_language(CALL "${hook}" ${ARGV}) + else() + set(temp_file ".qt-run-deploy-hook.cmake") + file(WRITE "${temp_file}" "${hook}(${ARGV})") + include(${temp_file}) + file(REMOVE "${temp_file}") + endif() + endforeach() +endfunction() + function(_qt_internal_generic_deployqt) set(no_value_options NO_TRANSLATIONS @@ -273,6 +301,8 @@ function(_qt_internal_generic_deployqt) if(NOT arg_NO_TRANSLATIONS) qt6_deploy_translations() endif() + + _qt_internal_run_deployment_hooks(${ARGV} RESOLVED_DEPENDENCIES ${resolved}) endfunction() function(qt6_deploy_runtime_dependencies) @@ -293,6 +323,7 @@ function(qt6_deploy_runtime_dependencies) EXECUTABLE BIN_DIR LIB_DIR + LIBEXEC_DIR PLUGINS_DIR QML_DIR ) @@ -316,6 +347,7 @@ function(qt6_deploy_runtime_dependencies) ADDITIONAL_LIBRARIES ADDITIONAL_MODULES ${file_GRD_options} + DEPLOY_TOOL_OPTIONS ) cmake_parse_arguments(PARSE_ARGV 0 arg "${no_value_options}" "${single_value_options}" "${multi_value_options}" @@ -333,6 +365,9 @@ function(qt6_deploy_runtime_dependencies) if(NOT arg_BIN_DIR) set(arg_BIN_DIR "${QT_DEPLOY_BIN_DIR}") endif() + if(NOT arg_LIBEXEC_DIR) + set(arg_LIBEXEC_DIR "${QT_DEPLOY_LIBEXEC_DIR}") + endif() if(NOT arg_LIB_DIR) set(arg_LIB_DIR "${QT_DEPLOY_LIB_DIR}") endif() @@ -393,6 +428,8 @@ function(qt6_deploy_runtime_dependencies) --dir . --libdir "${arg_BIN_DIR}" # NOTE: Deliberately not arg_LIB_DIR --plugindir "${arg_PLUGINS_DIR}" + --qml-deploy-dir "${arg_QML_DIR}" + --translationdir "${QT_DEPLOY_TRANSLATIONS_DIR}" ) if(NOT arg_NO_OVERWRITE) list(APPEND tool_options --force) @@ -403,6 +440,19 @@ function(qt6_deploy_runtime_dependencies) if(arg_NO_COMPILER_RUNTIME) list(APPEND tool_options --no-compiler-runtime) endif() + + # Specify path to target Qt's qtpaths .exe or .bat file, so windeployqt deploys the correct + # libraries when cross-compiling from x86_64 to arm64 windows. + if(__QT_DEPLOY_TARGET_QT_PATHS_PATH AND EXISTS "${__QT_DEPLOY_TARGET_QT_PATHS_PATH}") + list(APPEND tool_options --qtpaths "${__QT_DEPLOY_TARGET_QT_PATHS_PATH}") + else() + message(WARNING + "No qtpaths executable found for target Qt " + "at: ${__QT_DEPLOY_TARGET_QT_PATHS_PATH}. " + "Libraries may not be deployed correctly.") + endif() + + list(APPEND tool_options ${arg_DEPLOY_TOOL_OPTIONS}) elseif(__QT_DEPLOY_SYSTEM_NAME STREQUAL Darwin) set(extra_binaries_option "-executable=") if(NOT arg_NO_APP_STORE_COMPLIANCE) @@ -411,6 +461,7 @@ function(qt6_deploy_runtime_dependencies) if(NOT arg_NO_OVERWRITE) list(APPEND tool_options -always-overwrite) endif() + list(APPEND tool_options ${arg_DEPLOY_TOOL_OPTIONS}) endif() # This is an internal variable. It is normally unset and is only intended @@ -420,6 +471,13 @@ function(qt6_deploy_runtime_dependencies) if(__QT_DEPLOY_TOOL STREQUAL "GRD") message(STATUS "Running generic Qt deploy tool on ${arg_EXECUTABLE}") + if(NOT "${arg_DEPLOY_TOOL_OPTIONS}" STREQUAL "") + message(WARNING + "DEPLOY_TOOL_OPTIONS was specified but has no effect when using the generic " + "deployment tool." + ) + endif() + # Construct the EXECUTABLES, LIBRARIES and MODULES arguments. list(APPEND tool_options EXECUTABLES ${arg_EXECUTABLE}) if(NOT "${arg_ADDITIONAL_EXECUTABLES}" STREQUAL "") @@ -488,10 +546,19 @@ if(NOT __QT_NO_CREATE_VERSIONLESS_FUNCTIONS) endif() function(_qt_internal_show_skip_runtime_deploy_message qt_build_type_string) + set(no_value_options "") + set(single_value_options + EXTRA_MESSAGE + ) + set(multi_value_options "") + cmake_parse_arguments(PARSE_ARGV 1 arg + "${no_value_options}" "${single_value_options}" "${multi_value_options}" + ) message(STATUS "Skipping runtime deployment steps. " "Support for installing runtime dependencies is not implemented for " - "this target platform (${__QT_DEPLOY_SYSTEM_NAME}, ${qt_build_type_string})." + "this target platform (${__QT_DEPLOY_SYSTEM_NAME}, ${qt_build_type_string}). " + "${arg_EXTRA_MESSAGE}" ) endfunction() @@ -518,34 +585,7 @@ function(qt6_deploy_translations) if(arg_CATALOGS) set(catalogs ${arg_CATALOGS}) else() - set(catalogs qt qtbase) - - # Find the translations that belong to the Qt modules that are used by the project. - # "Used by the project" means just all modules that are pulled in via find_package for now. - set(modules ${__QT_DEPLOY_ALL_MODULES_FOUND_VIA_FIND_PACKAGE}) - - set(module_catalog_mapping - "Bluetooth|Nfc" qtconnectivity - "Help" qt_help - "Multimedia(Widgets|QuickPrivate)?" qtmultimedia - "Qml|Quick" qtdeclarative - "SerialPort" qtserialport - "WebEngine" qtwebengine - "WebSockets" qtwebsockets - ) - list(LENGTH module_catalog_mapping max_i) - math(EXPR max_i "${max_i} - 1") - foreach(module IN LISTS modules) - foreach(i RANGE 0 ${max_i} 2) - list(GET module_catalog_mapping ${i} module_rex) - if(NOT module MATCHES "^${module_rex}") - continue() - endif() - math(EXPR k "${i} + 1") - list(GET module_catalog_mapping ${k} catalog) - list(APPEND catalogs ${catalog}) - endforeach() - endforeach() + set(catalogs ${__QT_DEPLOY_I18N_CATALOGS}) endif() get_filename_component(qt_translations_dir "${__QT_DEPLOY_QT_INSTALL_TRANSLATIONS}" ABSOLUTE |