CMake: Introduce wrappers for the PlatformX and GlobalConfig targets

Introduce some command wrappers for adding the Platform,
PlatformXInternal and GlobalConfig targets, to apply some common
options.

This will allow for less churn in the future when we need to apply
options to all these targets.

The Qt6CoreMacros, Qt6AndroidMacros and Qt6WasmMacros inclusion are
moved before QtBaseGlobalTargets to make the
_qt_internal_add_library command and other platform specific
commands available before we create the Platform targets.

Change-Id: I260fdbeb95a39f06951dfefc714d3da604abb0bb
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit af60bdee8dcb86b73caa23d4d54611b0f1d33bf3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Alexandru Croitor 2024-07-02 15:44:02 +02:00 committed by Qt Cherry-pick Bot
parent 1a4369d9ac
commit 1da1e23704
5 changed files with 45 additions and 51 deletions

View File

@ -68,7 +68,7 @@ qt_internal_create_toolchain_file()
## Library to hold global features:
## These features are stored and accessed via Qt::GlobalConfig, but the
## files always lived in Qt::Core, so we keep it that way
add_library(GlobalConfig INTERFACE)
qt_internal_add_platform_internal_target(GlobalConfig)
target_include_directories(GlobalConfig INTERFACE
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/QtCore>
@ -121,9 +121,8 @@ qt_generate_qmake_and_qtpaths_wrapper_for_target()
# Depends on the global features being evaluated.
qt_internal_create_wrapper_scripts()
add_library(Qt::GlobalConfig ALIAS GlobalConfig)
add_library(GlobalConfigPrivate INTERFACE)
qt_internal_add_platform_internal_target(GlobalConfigPrivate)
target_link_libraries(GlobalConfigPrivate INTERFACE GlobalConfig)
target_include_directories(GlobalConfigPrivate INTERFACE
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/QtCore/${PROJECT_VERSION}>
@ -131,12 +130,6 @@ target_include_directories(GlobalConfigPrivate INTERFACE
$<INSTALL_INTERFACE:${INSTALL_INCLUDEDIR}/QtCore/${PROJECT_VERSION}>
$<INSTALL_INTERFACE:${INSTALL_INCLUDEDIR}/QtCore/${PROJECT_VERSION}/QtCore>
)
add_library(Qt::GlobalConfigPrivate ALIAS GlobalConfigPrivate)
add_library(${QT_CMAKE_EXPORT_NAMESPACE}::GlobalConfigPrivate ALIAS GlobalConfigPrivate)
qt_internal_add_sbom(GlobalConfigPrivate
TYPE QT_MODULE
IMMEDIATE_FINALIZATION
)
qt_internal_setup_public_platform_target()

View File

@ -166,6 +166,22 @@ macro(qt_internal_qtbase_build_repo)
## Build System tests:
include(QtBaseCMakeTesting)
## Include CoreMacros() for qt6_generate_meta_types()
## Also needed for the QtBaseGlobalTargets creation.
set(QT_DEFAULT_MAJOR_VERSION 6)
include(src/corelib/Qt6CoreMacros.cmake)
# Needed when building qtbase for android.
if(ANDROID)
include(src/corelib/Qt6AndroidMacros.cmake)
endif()
# Needed when building for WebAssembly.
if(WASM)
include(cmake/QtWasmHelpers.cmake)
include(src/corelib/Qt6WasmMacros.cmake)
endif()
## Targets for global features, etc.:
include(QtBaseGlobalTargets)
@ -173,20 +189,11 @@ macro(qt_internal_qtbase_build_repo)
## feature variables are available.
qt_set_language_standards()
#include CoreMacros() for qt6_generate_meta_types()
set(QT_DEFAULT_MAJOR_VERSION 6)
include(src/corelib/Qt6CoreMacros.cmake)
# Needed when building qtbase for android.
if(ANDROID)
include(src/corelib/Qt6AndroidMacros.cmake)
_qt_internal_create_global_android_targets()
endif()
if(WASM)
# Needed when building for WebAssembly.
include(cmake/QtWasmHelpers.cmake)
include(src/corelib/Qt6WasmMacros.cmake)
qt_internal_setup_wasm_target_properties(Platform)
endif()

View File

@ -133,45 +133,20 @@ function(qt_internal_add_global_definition definition)
endif()
endfunction()
add_library(PlatformCommonInternal INTERFACE)
qt_internal_add_target_aliases(PlatformCommonInternal)
qt_internal_add_platform_internal_target(PlatformCommonInternal)
target_link_libraries(PlatformCommonInternal INTERFACE Platform)
qt_internal_add_sbom(PlatformCommonInternal
TYPE QT_MODULE
IMMEDIATE_FINALIZATION
)
add_library(PlatformModuleInternal INTERFACE)
qt_internal_add_target_aliases(PlatformModuleInternal)
qt_internal_add_platform_internal_target(PlatformModuleInternal)
target_link_libraries(PlatformModuleInternal INTERFACE PlatformCommonInternal)
qt_internal_add_sbom(PlatformModuleInternal
TYPE QT_MODULE
IMMEDIATE_FINALIZATION
)
add_library(PlatformPluginInternal INTERFACE)
qt_internal_add_target_aliases(PlatformPluginInternal)
qt_internal_add_platform_internal_target(PlatformPluginInternal)
target_link_libraries(PlatformPluginInternal INTERFACE PlatformCommonInternal)
qt_internal_add_sbom(PlatformPluginInternal
TYPE QT_MODULE
IMMEDIATE_FINALIZATION
)
add_library(PlatformAppInternal INTERFACE)
qt_internal_add_target_aliases(PlatformAppInternal)
qt_internal_add_platform_internal_target(PlatformAppInternal)
target_link_libraries(PlatformAppInternal INTERFACE PlatformCommonInternal)
qt_internal_add_sbom(PlatformAppInternal
TYPE QT_MODULE
IMMEDIATE_FINALIZATION
)
add_library(PlatformToolInternal INTERFACE)
qt_internal_add_target_aliases(PlatformToolInternal)
qt_internal_add_platform_internal_target(PlatformToolInternal)
target_link_libraries(PlatformToolInternal INTERFACE PlatformAppInternal)
qt_internal_add_sbom(PlatformToolInternal
TYPE QT_MODULE
IMMEDIATE_FINALIZATION
)
qt_internal_add_global_definition(QT_NO_JAVA_STYLE_ITERATORS)
qt_internal_add_global_definition(QT_NO_QASCONST)

View File

@ -10,9 +10,7 @@ function(qt_internal_setup_public_platform_target)
)
## QtPlatform Target:
add_library(Platform INTERFACE)
add_library(Qt::Platform ALIAS Platform)
add_library(${INSTALL_CMAKE_NAMESPACE}::Platform ALIAS Platform)
qt_internal_add_platform_target(Platform)
target_include_directories(Platform
INTERFACE
$<BUILD_INTERFACE:${build_interface_definition_dir}>

View File

@ -1730,6 +1730,27 @@ function(qt_internal_export_genex_properties)
)
endfunction()
# A small wrapper for adding the Platform target, and a building block for the PlatformXInternal
# and GlobalConfig INTERFACE targets to apply common options.
function(qt_internal_add_platform_target target)
_qt_internal_add_library("${target}" INTERFACE)
qt_internal_add_target_aliases("${target}")
endfunction()
# A small wrapper for adding the PlatformXInternal and GlobalConfig INTERFACE targets to apply
# common options.
# They can't be added via qt_internal_add_module, because it automatically links to the
# PlatformInternal targets creating a cyclic dependency.
function(qt_internal_add_platform_internal_target target)
qt_internal_add_platform_target("${target}")
qt_internal_mark_as_internal_library("${target}")
qt_internal_add_sbom("${target}"
TYPE QT_MODULE
IMMEDIATE_FINALIZATION
)
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.