Add the the implicit promotion to global for Qt platform targets
Bundled 3rdparty libraries link Qt platform targets implicitly, which lead to the dependency resolution when the library is used by another targets. For qtbase this works just fine since all platform targets are not imported and they are used from a build tree. But in case if 3rdparty library is built as part of Qt repo different from qtbase platform targets are imported and trigger the global promotion in CMake. Usually qt_find_package for the 3rdparty libraries is called somewhere in src/... directory and since Qt::Platform* targets are already created in the top-level repo CMakeLists.txt by the find_package(Qt ...) call, this leads to an error. The propsed fix forces the global promotion of Qt platform targets as soon as they created by the one of the initial find_package(Qt ...) calls. Change-Id: Iceb53f9ecccbdc438f9bc3bcc836583cfd4de535 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
parent
180afc7321
commit
161c2f9544
@ -11,6 +11,7 @@ macro(qt_internal_project_setup)
|
||||
# Check for the minimum CMake version.
|
||||
qt_internal_require_suitable_cmake_version()
|
||||
qt_internal_upgrade_cmake_policies()
|
||||
qt_internal_promote_platform_targets_to_global()
|
||||
endmacro()
|
||||
|
||||
macro(qt_build_internals_set_up_private_api)
|
||||
|
@ -1582,3 +1582,32 @@ function(qt_internal_export_genex_properties)
|
||||
COMPONENT Devel
|
||||
)
|
||||
endfunction()
|
||||
|
||||
# The macro promotes the Qt platform targets and their dependencies to global. The macro shouldn't
|
||||
# be called explicitly in regular cases. It's called right after the first find_package(Qt ...)
|
||||
# call in the qt_internal_project_setup macro.
|
||||
# This allows using the qt_find_package(Wrap<3rdparty> PROVIDED_TARGETS ...) function,
|
||||
# without the risk of having duplicated global promotion of Qt internals. This is especially
|
||||
# sensitive for the bundled 3rdparty libraries.
|
||||
macro(qt_internal_promote_platform_targets_to_global)
|
||||
if(TARGET Qt6::Platform)
|
||||
get_target_property(is_imported Qt6::Platform IMPORTED)
|
||||
if(is_imported)
|
||||
set(known_platform_targets
|
||||
Platform
|
||||
PlatformCommonInternal
|
||||
PlatformModuleInternal
|
||||
PlatformPluginInternal
|
||||
PlatformAppInternal
|
||||
PlatformToolInternal
|
||||
)
|
||||
set(versionless_platform_targets ${known_platform_targets})
|
||||
|
||||
list(TRANSFORM known_platform_targets PREPEND Qt6::)
|
||||
list(TRANSFORM versionless_platform_targets PREPEND Qt::)
|
||||
qt_find_package(Qt6 PROVIDED_TARGETS
|
||||
${known_platform_targets}
|
||||
${versionless_platform_targets})
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
Loading…
x
Reference in New Issue
Block a user