summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2021-09-07 18:43:20 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2021-09-16 20:59:35 +0200
commitd470497d9a05fbdc251a2524f2d11ea6f90fa7c6 (patch)
tree4a6a420c28ba8851e27d71bd5857de1ab5b3766a /cmake
parent5f3e8dde958d2c218b90884d4a368fe9860a41b5 (diff)
CMake: Make standalone tests TestsConfig file repo-target-set specific
Conan CI builds can built a qt repository in a repo-target-set configuration. An example of that is qtscxml. When building standalone tests, qt_build_tests includes a repo specific TestsConfig.cmake file to call find_package on the modules that were built as part of that repo. That doesn't quite work with a repo-target-set build which is enabled when the repo is built with a QT_BUILD_SINGLE_REPO_TARGET_SET value. The TestsConfig.cmake file would be overridden with different contents on each configuration. Fix that by including the QT_BUILD_SINGLE_REPO_TARGET_SET value as part of the TestsConfig.cmake file to be generated and included. This means that when configuring the standalone tests, the same QT_BUILD_SINGLE_REPO_TARGET_SET value should be passed, so that the correct packages are found. Add some debug statements to allow checking which TestsConfig.cmake file is loaded when the standalone tests are configured with --log-level=DEBUG. Adjusts to 4b09522c23e9efdf83ba8d4af436d8a700ccb66e Amends de3a806def4b9a754825a2233c9d4952a9b2d0eb Amends e7f188b2d2f10941006be7b0e7197b3c1ebdefdb Pick-to: 6.2 Task-number: QTBUG-96253 Change-Id: I7c22aaad88fe8e6fce23046543363316203f6e8d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtBuildInternals/QtBuildInternalsConfig.cmake37
-rw-r--r--cmake/QtPostProcessHelpers.cmake5
2 files changed, 39 insertions, 3 deletions
diff --git a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
index 0d2da108ef..d46917f1a7 100644
--- a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
+++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
@@ -555,12 +555,47 @@ function(qt_get_standalone_tests_config_files_path out_var)
set("${out_var}" "${path}" PARENT_SCOPE)
endfunction()
+function(qt_internal_get_standalone_tests_config_file_name out_var)
+ # When doing a "single repo target set" build (like in qtscxqml) ensure we use a unique tests
+ # config file for each repo target set. Using the PROJECT_NAME only is not enough because
+ # the same file will be overridden with different content on each repo set install.
+ set(tests_config_file_name "${PROJECT_NAME}")
+
+ if(QT_BUILD_SINGLE_REPO_TARGET_SET)
+ string(APPEND tests_config_file_name "RepoSet${QT_BUILD_SINGLE_REPO_TARGET_SET}")
+ endif()
+ string(APPEND tests_config_file_name "TestsConfig.cmake")
+
+ set(${out_var} "${tests_config_file_name}" PARENT_SCOPE)
+endfunction()
+
macro(qt_build_tests)
if(QT_BUILD_STANDALONE_TESTS)
# Find location of TestsConfig.cmake. These contain the modules that need to be
# find_package'd when testing.
qt_get_standalone_tests_config_files_path(_qt_build_tests_install_prefix)
- include("${_qt_build_tests_install_prefix}/${PROJECT_NAME}TestsConfig.cmake" OPTIONAL)
+
+ qt_internal_get_standalone_tests_config_file_name(_qt_tests_config_file_name)
+ set(_qt_standalone_tests_config_file_path
+ "${_qt_build_tests_install_prefix}/${_qt_tests_config_file_name}")
+ include("${_qt_standalone_tests_config_file_path}"
+ OPTIONAL
+ RESULT_VARIABLE _qt_standalone_tests_included)
+ if(NOT _qt_standalone_tests_included)
+ message(DEBUG
+ "Standalone tests config file not included because it does not exist: "
+ "${_qt_standalone_tests_config_file_path}"
+ )
+ else()
+ message(DEBUG
+ "Standalone tests config file included successfully: "
+ "${_qt_standalone_tests_config_file_path}"
+ )
+ endif()
+
+ unset(_qt_standalone_tests_config_file_path)
+ unset(_qt_standalone_tests_included)
+ unset(_qt_tests_config_file_name)
# Of course we always need the test module as well.
find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS Test)
diff --git a/cmake/QtPostProcessHelpers.cmake b/cmake/QtPostProcessHelpers.cmake
index 32046c3948..ba564dbae7 100644
--- a/cmake/QtPostProcessHelpers.cmake
+++ b/cmake/QtPostProcessHelpers.cmake
@@ -733,13 +733,14 @@ function(qt_internal_create_config_file_for_standalone_tests)
# Ceate a Config file that calls find_package on the modules that were built as part
# of the current repo. This is used for standalone tests.
+ qt_internal_get_standalone_tests_config_file_name(tests_config_file_name)
configure_file(
"${QT_CMAKE_DIR}/QtStandaloneTestsConfig.cmake.in"
- "${config_build_dir}/${PROJECT_NAME}TestsConfig.cmake"
+ "${config_build_dir}/${tests_config_file_name}"
@ONLY
)
qt_install(FILES
- "${config_build_dir}/${PROJECT_NAME}TestsConfig.cmake"
+ "${config_build_dir}/${tests_config_file_name}"
DESTINATION "${config_install_dir}"
COMPONENT Devel
)