diff --git a/cmake/QtPublicPluginHelpers.cmake b/cmake/QtPublicPluginHelpers.cmake index b0324585ac0..5a4777a0761 100644 --- a/cmake/QtPublicPluginHelpers.cmake +++ b/cmake/QtPublicPluginHelpers.cmake @@ -416,7 +416,24 @@ function(__qt_internal_collect_plugin_targets_from_dependencies_of_plugins targe set("${out_var}" "${plugin_targets}" PARENT_SCOPE) endfunction() -function(__qt_internal_generate_plugin_deployment_info target plugin_targets) +# Generate plugin information files for deployment +# +# Arguments: +# OUT_PLUGIN_TARGETS - Variable name to store the plugin targets that were collected with +# __qt_internal_collect_plugin_targets_from_dependencies. +function(__qt_internal_generate_plugin_deployment_info target) + set(no_value_options "") + set(single_value_options "OUT_PLUGIN_TARGETS") + set(multi_value_options "") + cmake_parse_arguments(PARSE_ARGV 0 arg + "${no_value_options}" "${single_value_options}" "${multi_value_options}" + ) + + __qt_internal_collect_plugin_targets_from_dependencies("${target}" plugin_targets) + if(NOT "${arg_OUT_PLUGIN_TARGETS}" STREQUAL "") + set("${arg_OUT_PLUGIN_TARGETS}" "${plugin_targets}" PARENT_SCOPE) + endif() + get_target_property(marked_for_deployment ${target} _qt_marked_for_deployment) if(NOT marked_for_deployment) return() @@ -447,8 +464,8 @@ function(__qt_internal_apply_plugin_imports_finalizer_mode target) return() endif() - __qt_internal_collect_plugin_targets_from_dependencies("${target}" plugin_targets) - __qt_internal_generate_plugin_deployment_info(${target} "${plugin_targets}") + __qt_internal_generate_plugin_deployment_info(${target} + OUT_PLUGIN_TARGETS plugin_targets) # By default if the project hasn't explicitly opted in or out, use finalizer mode. # The precondition for this is that qt_finalize_target was called (either explicitly by the user diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake index c1ea6fde58c..44f0a86aaa5 100644 --- a/src/corelib/Qt6CoreMacros.cmake +++ b/src/corelib/Qt6CoreMacros.cmake @@ -2910,6 +2910,13 @@ function(qt6_generate_deploy_script) # Mark the target as "to be deployed". set_property(TARGET ${arg_TARGET} PROPERTY _qt_marked_for_deployment ON) + # If the target already was finalized, maybe because it was defined in a subdirectory, generate + # the plugin deployment information here. + get_target_property(is_finalized "${arg_TARGET}" _qt_is_finalized) + if(is_finalized) + __qt_internal_generate_plugin_deployment_info(${arg_TARGET}) + endif() + # Create a file name that will be unique for this target and the combination # of arguments passed to this command. This allows the project to call us # multiple times with different arguments for the same target (e.g. to