Introduce the qt_internal_project_setup macro

The macro sets the required CMake variables and policies and
should be called right after the
find_package(Qt6 COMPONENTS BuildInternals... call to make sure that
the subsequent code adopt all the required policies.

Pick-to: 6.5
Task-number: QTBUG-112685
Change-Id: I9f93f728ee4d8ae7743db9fffafa26025c76dcf2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Alexey Edelev 2023-04-12 15:04:14 +02:00
parent a92c202b49
commit f3c10280f5
7 changed files with 18 additions and 2 deletions

View File

@ -107,6 +107,8 @@ else()
find_package(Qt6 REQUIRED COMPONENTS BuildInternals CMAKE_FIND_ROOT_PATH_BOTH) find_package(Qt6 REQUIRED COMPONENTS BuildInternals CMAKE_FIND_ROOT_PATH_BOTH)
endif() endif()
qt_internal_project_setup()
qt_build_repo_begin() qt_build_repo_begin()
if(NOT QT_BUILD_STANDALONE_TESTS) if(NOT QT_BUILD_STANDALONE_TESTS)

View File

@ -230,11 +230,20 @@ if(NOT QT_BUILD_INTERNALS_SKIP_SYSTEM_PREFIX_ADJUSTMENT)
qt_build_internals_set_up_system_prefixes() qt_build_internals_set_up_system_prefixes()
endif() endif()
macro(qt_build_internals_set_up_private_api) # The macro sets all the necessary pre-conditions and setup consistent environment for building
# the Qt repository. It has to be called right after the find_package(Qt6 COMPONENTS BuildInternals)
# call. Otherwise we cannot make sure that all the required policies will be applied to the Qt
# components that are involved in build procedure.
macro(qt_internal_project_setup)
# Check for the minimum CMake version. # Check for the minimum CMake version.
include(QtCMakeVersionHelpers) include(QtCMakeVersionHelpers)
qt_internal_require_suitable_cmake_version() qt_internal_require_suitable_cmake_version()
qt_internal_upgrade_cmake_policies() qt_internal_upgrade_cmake_policies()
endmacro()
macro(qt_build_internals_set_up_private_api)
# TODO: this call needs to be removed once all repositories got the qtbase update
qt_internal_project_setup()
# Qt specific setup common for all modules: # Qt specific setup common for all modules:
include(QtSetup) include(QtSetup)

View File

@ -6,7 +6,7 @@ project(qt_single_test VERSION 6.0.0 LANGUAGES C CXX ASM)
find_package(Qt6 REQUIRED COMPONENTS BuildInternals Core) find_package(Qt6 REQUIRED COMPONENTS BuildInternals Core)
include(${CMAKE_CURRENT_LIST_DIR}/Main.cmake) include(${CMAKE_CURRENT_LIST_DIR}/Main.cmake NO_POLICY_SCOPE)
# Get the absolute path of the passed-in project dir, relative to the current working directory # Get the absolute path of the passed-in project dir, relative to the current working directory
# of the calling script, rather than relative to this source directory. # of the calling script, rather than relative to this source directory.

View File

@ -2,6 +2,7 @@
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
# Includes QtSetup and friends for private CMake API. # Includes QtSetup and friends for private CMake API.
qt_internal_project_setup()
qt_build_internals_set_up_private_api() qt_build_internals_set_up_private_api()
# Find all StandaloneTestsConfig.cmake files, and include them # Find all StandaloneTestsConfig.cmake files, and include them

View File

@ -12,6 +12,8 @@ project(QtMockPlugins
) )
find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS BuildInternals Core) find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS BuildInternals Core)
qt_internal_project_setup()
find_package(Qt6 ${PROJECT_VERSION} QUIET CONFIG OPTIONAL_COMPONENTS Gui Widgets Xml) find_package(Qt6 ${PROJECT_VERSION} QUIET CONFIG OPTIONAL_COMPONENTS Gui Widgets Xml)
qt_build_repo_begin() qt_build_repo_begin()

View File

@ -13,6 +13,7 @@ project(TestGeneratingCppExports
) )
find_package(Qt6 COMPONENTS Core BuildInternals Test CONFIG REQUIRED) find_package(Qt6 COMPONENTS Core BuildInternals Test CONFIG REQUIRED)
qt_internal_project_setup()
qt_build_repo_begin() qt_build_repo_begin()

View File

@ -13,6 +13,7 @@ project(TestStaticResources
) )
find_package(Qt6 COMPONENTS Core BuildInternals Test CONFIG REQUIRED) find_package(Qt6 COMPONENTS Core BuildInternals Test CONFIG REQUIRED)
qt_internal_project_setup()
qt_build_repo_begin() qt_build_repo_begin()