The _qt_internal_finalize_batch function had a bunch of problems, style-wise and function-wise: - it called find_package(Qt6) in its body, which broke when configuring qtbase with in-tree tests - it constantly rewrote the merged blacklist file on each reconfiguration - it used file(WRITE) to concatenate content - it was in the public API file The changes are: - Move the function to the internal test helpers file. - Change it to use qt_configure_file instead of file(WRITE). - Call it at the end of the qt_build_tests for a repo, or at the end of configuring a super build, instead of relying on a finalizer. - Remove the find_package call. The reason this was added in the first place, was to populate the __qt_core_macros_module_base_dir variable so that qt_internal_add_resource configure_file call doesn't fail in standalone tests build. The variable was unset because the finalized function was called in the top level directory scope, whereas the very first find_package call was in the tests/ scope, meaning the variable was empty. This is still a problem in the top-level build where the tests scope and the top-level scope are different. Work around it by relying on a global property to reset the value if it's empty. Amends 6a9e89121d7766a34c4281d298057bfbe8af36b3 Pick-to: 6.8 Change-Id: Id6fe41ee86d09b8118bea52cac8a59965d7ecb9e Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
110 lines
3.9 KiB
CMake
110 lines
3.9 KiB
CMake
# Copyright (C) 2023 The Qt Company Ltd.
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
# There are three necessary copies of this macro in
|
|
# qtbase/cmake/QtBaseHelpers.cmake
|
|
# qtbase/cmake/QtBaseTopLevelHelpers.cmake
|
|
# qtbase/cmake/QtBuildRepoHelpers.cmake
|
|
macro(qt_internal_top_level_setup_standalone_parts)
|
|
# A generic marker for any kind of standalone builds, either tests or examples.
|
|
if(NOT DEFINED QT_INTERNAL_BUILD_STANDALONE_PARTS
|
|
AND (QT_BUILD_STANDALONE_TESTS OR QT_BUILD_STANDALONE_EXAMPLES))
|
|
set(QT_INTERNAL_BUILD_STANDALONE_PARTS TRUE CACHE INTERNAL
|
|
"Whether standalone tests or examples are being built")
|
|
endif()
|
|
endmacro()
|
|
|
|
# Depends on __qt6_qtbase_src_path being set in the top-level dir.
|
|
macro(qt_internal_top_level_setup_autodetect)
|
|
qt_internal_top_level_setup_standalone_parts()
|
|
|
|
# Run platform auto-detection /before/ the first project() call and thus
|
|
# before the toolchain file is loaded.
|
|
# Don't run auto-detection when doing standalone tests. In that case, the detection
|
|
# results are taken from either QtBuildInternals or the qt.toolchain.cmake file.
|
|
|
|
if(NOT QT_INTERNAL_BUILD_STANDALONE_PARTS)
|
|
set(__qt6_auto_detect_path "${__qt6_qtbase_src_path}/cmake/QtAutoDetect.cmake")
|
|
if(NOT EXISTS "${__qt6_auto_detect_path}")
|
|
message(FATAL_ERROR "Required file does not exist: '${__qt6_auto_detect_path}'")
|
|
endif()
|
|
include("${__qt6_auto_detect_path}")
|
|
endif()
|
|
endmacro()
|
|
|
|
macro(qt_internal_top_level_setup_after_project)
|
|
qt_internal_top_level_setup_testing()
|
|
endmacro()
|
|
|
|
macro(qt_internal_top_level_setup_testing)
|
|
# Required so we can call ctest from the root build directory
|
|
enable_testing()
|
|
endmacro()
|
|
|
|
# Depends on __qt6_qtbase_src_path being set in the top-level dir.
|
|
macro(qt_internal_top_level_setup_cmake_module_path)
|
|
if (NOT QT_INTERNAL_BUILD_STANDALONE_PARTS)
|
|
set(__qt6_cmake_module_path "${__qt6_qtbase_src_path}/cmake")
|
|
if(NOT EXISTS "${__qt6_cmake_module_path}")
|
|
message(FATAL_ERROR "Required directory does not exist: '${__qt6_cmake_module_path}'")
|
|
endif()
|
|
|
|
list(APPEND CMAKE_MODULE_PATH "${__qt6_cmake_module_path}")
|
|
|
|
list(APPEND CMAKE_MODULE_PATH
|
|
"${__qt6_cmake_module_path}/3rdparty/extra-cmake-modules/find-modules")
|
|
list(APPEND CMAKE_MODULE_PATH "${__qt6_cmake_module_path}/3rdparty/kwin")
|
|
endif()
|
|
endmacro()
|
|
|
|
macro(qt_internal_top_level_before_build_submodules)
|
|
qt_internal_top_level_setup_no_create_targets()
|
|
endmacro()
|
|
|
|
macro(qt_internal_top_level_setup_no_create_targets)
|
|
# Also make sure the CMake config files do not recreate the already-existing targets
|
|
if (NOT QT_INTERNAL_BUILD_STANDALONE_PARTS)
|
|
set(QT_NO_CREATE_TARGETS TRUE)
|
|
endif()
|
|
endmacro()
|
|
|
|
macro(qt_internal_top_level_end)
|
|
if(QT_BUILD_TESTS)
|
|
qt_internal_finalize_test_batch_blacklist()
|
|
endif()
|
|
|
|
qt_internal_print_top_level_info()
|
|
|
|
# Depends on QtBuildInternalsConfig being included, which is the case whenver any repo is
|
|
# configured.
|
|
qt_internal_qt_configure_end()
|
|
|
|
if(QT_WILL_INSTALL AND QT_INSTALL_CONFIG_INFO_FILES)
|
|
qt_install(
|
|
FILES
|
|
"${CMAKE_BINARY_DIR}/config.opt"
|
|
"${CMAKE_BINARY_DIR}/config.summary"
|
|
DESTINATION ${INSTALL_DATADIR}
|
|
)
|
|
endif()
|
|
endmacro()
|
|
|
|
function(qt_internal_print_top_level_info)
|
|
if(NOT QT_INTERNAL_BUILD_STANDALONE_PARTS)
|
|
# Display a summary of everything
|
|
include(QtBuildInformation)
|
|
include(QtPlatformSupport)
|
|
qt_print_feature_summary()
|
|
qt_print_build_instructions()
|
|
endif()
|
|
endfunction()
|
|
|
|
macro(qt_internal_top_level_after_add_subdirectory)
|
|
if(module STREQUAL "qtbase")
|
|
if (NOT QT_INTERNAL_BUILD_STANDALONE_PARTS)
|
|
list(APPEND CMAKE_PREFIX_PATH "${QtBase_BINARY_DIR}/${INSTALL_LIBDIR}/cmake")
|
|
list(APPEND CMAKE_FIND_ROOT_PATH "${QtBase_BINARY_DIR}")
|
|
endif()
|
|
endif()
|
|
endmacro()
|