From a57412878c921494fce06ef5856eac98c1207329 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Fri, 17 Nov 2023 16:46:45 +0100 Subject: [PATCH] CMake: Mostly unify includes into a single location Make the QtBuildRepoHelpers and QtBuildRepoExamplesHelpers files that were previously loaded as part of BuildInternals package instead be loaded when qt_internal_include_all_helpers is called. Load all the helpers as soon as find_package(QtBuildInternals) is called rather than when qt_build_repo() is called. This is a behavior change, but because including the Qt's Helpers should have no side-effects aside from defining functions, it should be fine. This lets us have a unified location where to include Helpers files, instead of thinking whether it needs to be done in QtBuildInternals or in QtBuildHelpers or some other place. Move also some additional inclusions into the same function. Note that including some upstream CMake files like CMakeFindBinUtils does have side-effects, but we've been doing it already anyway, so moving it to the top should not make a difference because any modifications we would do to the globally assigned variables would have come later when we actually called our own functions. Task-number: QTBUG-86035 Change-Id: I33f36f7e8db69d504c34a4d4a094b98f6fa50ee4 Reviewed-by: Qt CI Bot Reviewed-by: Alexey Edelev (cherry picked from commit 2b1f2338631ae24614637b90c45f2778c3c77e37) --- cmake/QtBaseGlobalTargets.cmake | 3 --- cmake/QtBuild.cmake | 3 --- cmake/QtBuildHelpers.cmake | 9 +++++++++ cmake/QtBuildInformation.cmake | 1 - cmake/QtBuildInternals/QtBuildInternalsConfig.cmake | 4 ++-- cmake/QtBuildRepoHelpers.cmake | 2 -- cmake/QtPostProcess.cmake | 2 -- cmake/QtSeparateDebugInfo.cmake | 2 -- 8 files changed, 11 insertions(+), 15 deletions(-) diff --git a/cmake/QtBaseGlobalTargets.cmake b/cmake/QtBaseGlobalTargets.cmake index 1716c3a3fcf..b32692805db 100644 --- a/cmake/QtBaseGlobalTargets.cmake +++ b/cmake/QtBaseGlobalTargets.cmake @@ -63,10 +63,8 @@ qt_copy_or_install( set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/QtBuildInternals/${__build_internals_standalone_test_template_dir}/CMakeLists.txt") -include(QtToolchainHelpers) qt_internal_create_toolchain_file() -include(QtWrapperScriptHelpers) qt_internal_create_wrapper_scripts() ## Library to hold global features: @@ -134,7 +132,6 @@ target_include_directories(GlobalConfigPrivate INTERFACE ) add_library(Qt::GlobalConfigPrivate ALIAS GlobalConfigPrivate) -include(QtPlatformTargetHelpers) qt_internal_setup_public_platform_target() # defines PlatformCommonInternal PlatformModuleInternal PlatformPluginInternal PlatformToolInternal diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index 2af9dd6e8d9..ee24ba188eb 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -1,7 +1,4 @@ # Copyright (C) 2022 The Qt Company Ltd. # SPDX-License-Identifier: BSD-3-Clause -include(QtBuildHelpers) - -qt_internal_include_all_helpers() qt_internal_setup_build_and_global_variables() diff --git a/cmake/QtBuildHelpers.cmake b/cmake/QtBuildHelpers.cmake index 62a3b3d5c93..5abc1ad7987 100644 --- a/cmake/QtBuildHelpers.cmake +++ b/cmake/QtBuildHelpers.cmake @@ -123,7 +123,9 @@ endmacro() macro(qt_internal_include_all_helpers) # Upstream cmake modules. include(CheckCXXSourceCompiles) + include(CMakeFindBinUtils) include(CMakePackageConfigHelpers) + include(FeatureSummary) # Internal helpers available only while building Qt itself. include(Qt3rdPartyLibraryHelpers) @@ -133,7 +135,10 @@ macro(qt_internal_include_all_helpers) include(QtBuildInformation) include(QtBuildOptionsHelpers) include(QtBuildPathsHelpers) + include(QtBuildRepoExamplesHelpers) + include(QtBuildRepoHelpers) include(QtCMakeHelpers) + include(QtCMakeVersionHelpers) include(QtDbusHelpers) include(QtDeferredDependenciesHelpers) include(QtDocsHelpers) @@ -151,7 +156,9 @@ macro(qt_internal_include_all_helpers) include(QtModuleHelpers) include(QtNoLinkTargetHelpers) include(QtPkgConfigHelpers) + include(QtPlatformTargetHelpers) include(QtPluginHelpers) + include(QtPostProcessHelpers) include(QtPrecompiledHeadersHelpers) include(QtPriHelpers) include(QtPrlHelpers) @@ -166,9 +173,11 @@ macro(qt_internal_include_all_helpers) include(QtSyncQtHelpers) include(QtTargetHelpers) include(QtTestHelpers) + include(QtToolchainHelpers) include(QtToolHelpers) include(QtUnityBuildHelpers) include(QtWasmHelpers) + include(QtWrapperScriptHelpers) # Helpers that are available in public projects and while building Qt itself. include(QtPublicAppleHelpers) diff --git a/cmake/QtBuildInformation.cmake b/cmake/QtBuildInformation.cmake index 40c95ac633f..165b9c97ee0 100644 --- a/cmake/QtBuildInformation.cmake +++ b/cmake/QtBuildInformation.cmake @@ -27,7 +27,6 @@ function(qt_print_feature_summary) endif() endif() - include(FeatureSummary) # Show which packages were found. feature_summary(INCLUDE_QUIET_PACKAGES WHAT PACKAGES_FOUND diff --git a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake index d1857521b2e..129f1ebb771 100644 --- a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake +++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake @@ -62,7 +62,7 @@ if(NOT QT_BUILD_INTERNALS_SKIP_CMAKE_MODULE_PATH_ADDITION) qt_set_up_build_internals_paths() endif() -include(QtBuildRepoExamplesHelpers) -include(QtBuildRepoHelpers) +include(QtBuildHelpers) +qt_internal_include_all_helpers() qt_internal_setup_build_internals() diff --git a/cmake/QtBuildRepoHelpers.cmake b/cmake/QtBuildRepoHelpers.cmake index 87be088b6e7..f02d8466385 100644 --- a/cmake/QtBuildRepoHelpers.cmake +++ b/cmake/QtBuildRepoHelpers.cmake @@ -9,7 +9,6 @@ # components that are involved in build procedure. macro(qt_internal_project_setup) # Check for the minimum CMake version. - include(QtCMakeVersionHelpers) qt_internal_require_suitable_cmake_version() qt_internal_upgrade_cmake_policies() endmacro() @@ -20,7 +19,6 @@ macro(qt_build_internals_set_up_private_api) # Qt specific setup common for all modules: include(QtSetup) - include(FeatureSummary) # Optionally include a repo specific Setup module. include(${PROJECT_NAME}Setup OPTIONAL) diff --git a/cmake/QtPostProcess.cmake b/cmake/QtPostProcess.cmake index b178372c609..f69448c14a4 100644 --- a/cmake/QtPostProcess.cmake +++ b/cmake/QtPostProcess.cmake @@ -1,8 +1,6 @@ # Copyright (C) 2022 The Qt Company Ltd. # SPDX-License-Identifier: BSD-3-Clause -include(QtPostProcessHelpers) - qt_internal_create_depends_files() qt_generate_build_internals_extra_cmake_code() qt_internal_create_plugins_auto_inclusion_files() diff --git a/cmake/QtSeparateDebugInfo.cmake b/cmake/QtSeparateDebugInfo.cmake index 5b263585d3e..61f62207fab 100644 --- a/cmake/QtSeparateDebugInfo.cmake +++ b/cmake/QtSeparateDebugInfo.cmake @@ -1,8 +1,6 @@ # Copyright (C) 2022 The Qt Company Ltd. # SPDX-License-Identifier: BSD-3-Clause -include(CMakeFindBinUtils) - if(CMAKE_VERSION VERSION_LESS 3.17.0) set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}) endif()