From 303ee558dc08915e782eb441bb69c7a6ffa957cb Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Fri, 18 Nov 2022 15:13:19 +0100 Subject: [PATCH] Allow lists in the BUILD_OPTIONS argument of _qt_internal_test_expect_pass Adding the list definition to BUILD_OPTIONS requires unpleasant escapting. This avoids an extra expanding of the BUILD_OPTIONS argument and allows using the bracket-based escaping for semicolons. Change-Id: Ic5ff97c011fb67f61c66ad4e1a2ba43f44462932 Reviewed-by: Alexandru Croitor (cherry picked from commit 6aab2a58e6bffb2c0e21e3e9ad64b9396a9d6a82) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/Qt6CTestMacros.cmake | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/corelib/Qt6CTestMacros.cmake b/src/corelib/Qt6CTestMacros.cmake index b1d3f7e19d7..64a5d74870d 100644 --- a/src/corelib/Qt6CTestMacros.cmake +++ b/src/corelib/Qt6CTestMacros.cmake @@ -249,7 +249,11 @@ endfunction() # TESTNAME: a custom test name to use instead of the one derived from the source directory name # # 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) +# are ultimately passed to the CMake invocation of the test project). You may +# escape semicolons inside the definitions using: +# https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#bracket-argument +# so the argument containing list will look as following: +# -DLIST_ARGUMENT=item1[[;]]item2[[;]]...itemN. macro(_qt_internal_test_expect_pass _dir) set(_test_option_args SIMULATE_IN_SOURCE @@ -411,6 +415,8 @@ macro(_qt_internal_test_expect_pass _dir) ) endif() + string(REPLACE "[[;]]" "\;" _ARGS_BUILD_OPTIONS "${_ARGS_BUILD_OPTIONS}") + _qt_internal_get_cmake_test_configure_options(option_list) set(ctest_command_args --build-and-test @@ -422,7 +428,7 @@ macro(_qt_internal_test_expect_pass _dir) --build-makeprogram "${make_program}" ${build_project} --build-options "${option_list}" - ${_ARGS_BUILD_OPTIONS} ${additional_configure_args} + "${_ARGS_BUILD_OPTIONS}" ${additional_configure_args} ${test_command} ) add_test(${testname} ${CMAKE_CTEST_COMMAND} ${ctest_command_args})