diff --git a/src/corelib/Qt6CoreDeploySupport.cmake b/src/corelib/Qt6CoreDeploySupport.cmake index 1034368a631..388ab5fd042 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)