summaryrefslogtreecommitdiffstats
path: root/src/corelib/Qt6CTestMacros.cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2021-07-01 17:49:31 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2021-07-02 11:41:10 +0200
commitf95d03b3721369e3bd9e60c50f90405a617849cd (patch)
tree9f4887122d357c9fd96c7eb626bdceee78726ca4 /src/corelib/Qt6CTestMacros.cmake
parent468e4a8242da3e795fe0b218f97cfd97a1d7e032 (diff)
CMake: Allow specifying custom build directories for CMake autotests
It's useful when one project needs to be configured multiple times in different directories without overlapping CMakeCache.txt files, due to differing options passed during configuration. Pick-to: 6.2 Change-Id: Id2969e989824f980fba6ed58f9e0323ab3a862dd Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src/corelib/Qt6CTestMacros.cmake')
-rw-r--r--src/corelib/Qt6CTestMacros.cmake28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/corelib/Qt6CTestMacros.cmake b/src/corelib/Qt6CTestMacros.cmake
index 04595a776d..13d794024a 100644
--- a/src/corelib/Qt6CTestMacros.cmake
+++ b/src/corelib/Qt6CTestMacros.cmake
@@ -132,6 +132,10 @@ endfunction()
# This makes possible to have relative paths to the source files in the
# generated ninja rules.
#
+# BUILD_DIR: A custom build dir relative to the calling project CMAKE_CURRENT_BINARY_DIR.
+# Useful when configuring the same test project with different options in separate
+# build dirs.
+#
# BINARY: Path to the test artifact that will be executed after the build is complete. If a
# relative path is specified, it will be counted from the build directory.
# Can also be passed a random executable to be found in PATH, like 'ctest'.
@@ -143,8 +147,24 @@ endfunction()
# BUILD_OPTIONS: a list of -D style CMake definitions to pass to ctest's --build-options (which
# are ultimately passed to the CMake invocation of the test project)
macro(_qt_internal_test_expect_pass _dir)
- cmake_parse_arguments(_ARGS "SIMULATE_IN_SOURCE" "BINARY;TESTNAME" "BUILD_OPTIONS;BINARY_ARGS"
- ${ARGN})
+ set(_test_option_args
+ SIMULATE_IN_SOURCE
+ )
+ set(_test_single_args
+ BINARY
+ TESTNAME
+ BUILD_DIR
+ )
+ set(_test_multi_args
+ BUILD_OPTIONS
+ BINARY_ARGS
+ )
+ cmake_parse_arguments(_ARGS
+ "${_test_option_args}"
+ "${_test_single_args}"
+ "${_test_multi_args}"
+ ${ARGN}
+ )
if(_ARGS_TESTNAME)
set(testname "${_ARGS_TESTNAME}")
else()
@@ -157,6 +177,10 @@ macro(_qt_internal_test_expect_pass _dir)
string(REPLACE ";" "\;" __expect_pass_prefixes "${__expect_pass_prefixes}")
set(__expect_pass_build_dir "${CMAKE_CURRENT_BINARY_DIR}/${_dir}")
+ if(_ARGS_BUILD_DIR)
+ set(__expect_pass_build_dir "${CMAKE_CURRENT_BINARY_DIR}/${_ARGS_BUILD_DIR}")
+ endif()
+
set(__expect_pass_source_dir "${CMAKE_CURRENT_SOURCE_DIR}/${_dir}")
if(_ARGS_SIMULATE_IN_SOURCE)
set(__expect_pass_in_source_build_dir "${CMAKE_CURRENT_BINARY_DIR}/in_source")