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 <qt_ci_bot@qt-project.org> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> (cherry picked from commit 2b1f2338631ae24614637b90c45f2778c3c77e37)
69 lines
3.0 KiB
CMake
69 lines
3.0 KiB
CMake
# Copyright (C) 2022 The Qt Company Ltd.
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
# These values should be kept in sync with those in qtbase/.cmake.conf
|
|
cmake_minimum_required(VERSION 3.16...3.21)
|
|
|
|
set(QT_BACKUP_CMAKE_INSTALL_PREFIX_BEFORE_EXTRA_INCLUDE "${CMAKE_INSTALL_PREFIX}")
|
|
|
|
# This depends on qt_internal_read_repo_dependencies existing.
|
|
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/QtBuildInternalsExtra.cmake")
|
|
include(${CMAKE_CURRENT_LIST_DIR}/QtBuildInternalsExtra.cmake)
|
|
endif()
|
|
|
|
macro(qt_internal_setup_cmake_and_export_namespace)
|
|
# The variables might have already been set in QtBuildInternalsExtra.cmake if the file is
|
|
# included while building a new module and not QtBase. In that case, stop overriding the value.
|
|
if(NOT INSTALL_CMAKE_NAMESPACE)
|
|
set(INSTALL_CMAKE_NAMESPACE "Qt${PROJECT_VERSION_MAJOR}"
|
|
CACHE STRING "CMake namespace [Qt${PROJECT_VERSION_MAJOR}]")
|
|
endif()
|
|
if(NOT QT_CMAKE_EXPORT_NAMESPACE)
|
|
set(QT_CMAKE_EXPORT_NAMESPACE "Qt${PROJECT_VERSION_MAJOR}"
|
|
CACHE STRING "CMake namespace used when exporting targets [Qt${PROJECT_VERSION_MAJOR}]")
|
|
endif()
|
|
endmacro()
|
|
|
|
macro(qt_set_up_build_internals_paths)
|
|
# Set up the paths for the cmake modules located in the prefix dir. Prepend, so the paths are
|
|
# least important compared to the source dir ones, but more important than command line
|
|
# provided ones.
|
|
set(QT_CMAKE_MODULE_PATH "${QT_BUILD_INTERNALS_PATH}/../${QT_CMAKE_EXPORT_NAMESPACE}")
|
|
list(PREPEND CMAKE_MODULE_PATH "${QT_CMAKE_MODULE_PATH}")
|
|
|
|
# Prepend the qtbase source cmake directory to CMAKE_MODULE_PATH,
|
|
# so that if a change is done in cmake/QtBuild.cmake, it gets automatically picked up when
|
|
# building qtdeclarative, rather than having to build qtbase first (which will copy
|
|
# QtBuild.cmake to the build dir). This is similar to qmake non-prefix builds, where the
|
|
# source qtbase/mkspecs directory is used.
|
|
# TODO: Clean this up, together with qt_internal_try_compile_binary_for_strip to only use the
|
|
# the qtbase sources when building qtbase. And perhaps also when doing a non-prefix
|
|
# developer-build.
|
|
if(EXISTS "${QT_SOURCE_TREE}/cmake")
|
|
list(PREPEND CMAKE_MODULE_PATH "${QT_SOURCE_TREE}/cmake")
|
|
endif()
|
|
|
|
# If the repo has its own cmake modules, include those in the module path.
|
|
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
|
list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
|
endif()
|
|
|
|
# Find the cmake files when doing a standalone tests build.
|
|
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")
|
|
list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")
|
|
endif()
|
|
endmacro()
|
|
|
|
qt_internal_setup_cmake_and_export_namespace()
|
|
|
|
# Set up the build internal paths unless explicitly requested not to.
|
|
if(NOT QT_BUILD_INTERNALS_SKIP_CMAKE_MODULE_PATH_ADDITION)
|
|
# Depends on qt_internal_setup_cmake_and_export_namespace
|
|
qt_set_up_build_internals_paths()
|
|
endif()
|
|
|
|
include(QtBuildHelpers)
|
|
|
|
qt_internal_include_all_helpers()
|
|
qt_internal_setup_build_internals()
|