diff --git a/cmake/QtFindPackageHelpers.cmake b/cmake/QtFindPackageHelpers.cmake index cf2848d13bd..4ed79ec2a1e 100644 --- a/cmake/QtFindPackageHelpers.cmake +++ b/cmake/QtFindPackageHelpers.cmake @@ -1,21 +1,6 @@ # Copyright (C) 2022 The Qt Company Ltd. # SPDX-License-Identifier: BSD-3-Clause -# This function recursively walks transitive link libraries of the given target -# and promotes those targets to be IMPORTED_GLOBAL if they are not. -# -# This is required for .prl file generation in top-level builds, to make sure that imported 3rd -# party library targets in any repo are made global, so there are no scoping issues. -# -# Only works if called from qt_find_package(), because the promotion needs to happen in the same -# directory scope where the imported target is first created. -# -# Uses __qt_internal_walk_libs. -function(qt_find_package_promote_targets_to_global_scope target) - __qt_internal_walk_libs("${target}" _discarded_out_var _discarded_out_var_2 - "qt_find_package_targets_dict" "promote_global") -endfunction() - # As an optimization when using -developer-build, qt_find_package records which # packages were found during the initial configuration. Then on subsequent # reconfigurations it skips looking for packages that were not found on the @@ -226,11 +211,11 @@ macro(qt_find_package) get_property(is_global TARGET ${qt_find_package_target_name} PROPERTY IMPORTED_GLOBAL) - qt_internal_should_not_promote_package_target_to_global( + _qt_internal_should_not_promote_package_target_to_global( "${qt_find_package_target_name}" should_not_promote) if(NOT is_global AND NOT should_not_promote) __qt_internal_promote_target_to_global(${qt_find_package_target_name}) - qt_find_package_promote_targets_to_global_scope( + _qt_find_package_promote_targets_to_global_scope( "${qt_find_package_target_name}") endif() @@ -658,9 +643,3 @@ function(qt_register_target_dependencies target public_libs private_libs) set_target_properties("${target}" PROPERTIES _qt_target_deps "${target_deps}") endfunction() - -# Sets out_var to to TRUE if the target was marked to not be promoted to global scope. -function(qt_internal_should_not_promote_package_target_to_global target out_var) - get_property(should_not_promote TARGET "${target}" PROPERTY _qt_no_promote_global) - set("${out_var}" "${should_not_promote}" PARENT_SCOPE) -endfunction() diff --git a/cmake/QtPublicTargetHelpers.cmake b/cmake/QtPublicTargetHelpers.cmake index 02d55465608..c1735de8664 100644 --- a/cmake/QtPublicTargetHelpers.cmake +++ b/cmake/QtPublicTargetHelpers.cmake @@ -253,6 +253,27 @@ function(__qt_internal_collect_object_libraries_recursively out_var target initi set(${out_var} "${object_libraries}" PARENT_SCOPE) endfunction() +# Sets out_var to to TRUE if the target was marked to not be promoted to global scope. +function(_qt_internal_should_not_promote_package_target_to_global target out_var) + get_property(should_not_promote TARGET "${target}" PROPERTY _qt_no_promote_global) + set("${out_var}" "${should_not_promote}" PARENT_SCOPE) +endfunction() + +# This function recursively walks transitive link libraries of the given target +# and promotes those targets to be IMPORTED_GLOBAL if they are not. +# +# This is required for .prl file generation in top-level builds, to make sure that imported 3rd +# party library targets in any repo are made global, so there are no scoping issues. +# +# Only works if called from qt_find_package(), because the promotion needs to happen in the same +# directory scope where the imported target is first created. +# +# Uses __qt_internal_walk_libs. +function(_qt_find_package_promote_targets_to_global_scope target) + __qt_internal_walk_libs("${target}" _discarded_out_var _discarded_out_var_2 + "qt_find_package_targets_dict" "promote_global") +endfunction() + function(__qt_internal_promote_target_to_global target) get_property(is_global TARGET ${target} PROPERTY IMPORTED_GLOBAL) if(NOT is_global) diff --git a/cmake/QtPublicWalkLibsHelpers.cmake b/cmake/QtPublicWalkLibsHelpers.cmake index 7651d13690a..f801b1152e2 100644 --- a/cmake/QtPublicWalkLibsHelpers.cmake +++ b/cmake/QtPublicWalkLibsHelpers.cmake @@ -249,7 +249,7 @@ function(__qt_internal_walk_libs # Allow opting out of promotion. This is useful in certain corner cases # like with WrapLibClang and Threads in qttools. - qt_internal_should_not_promote_package_target_to_global( + _qt_internal_should_not_promote_package_target_to_global( "${lib_target_unaliased}" should_not_promote) if(is_imported AND NOT should_not_promote) __qt_internal_promote_target_to_global(${lib_target_unaliased})