From 3bee7db4198712c763dbd754bad7b2c851147038 Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Tue, 8 Feb 2022 15:25:52 +0100 Subject: [PATCH] Fix the run of _check targets in multi-config builds With Ninja Multi-Config generator it's necessary to provide the '-C' option matching the build configuration when running ctest. This patchset adds the missing option to the command line of the '_check' targets. Pick-to: 6.2 6.3 Change-Id: I42acfba26a09877a6d3a5be9230860f15f95a0cd Reviewed-by: Alexandru Croitor --- cmake/QtTestHelpers.cmake | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmake/QtTestHelpers.cmake b/cmake/QtTestHelpers.cmake index 70bca2267e..a076dd3fd7 100644 --- a/cmake/QtTestHelpers.cmake +++ b/cmake/QtTestHelpers.cmake @@ -346,10 +346,16 @@ function(qt_internal_add_test name) endif() # Add a ${target}/check makefile target, to more easily test one test. + + set(test_config_options "") + get_cmake_property(is_multi_config GENERATOR_IS_MULTI_CONFIG) + if(is_multi_config) + set(test_config_options -C $) + endif() add_custom_target("${name}_check" VERBATIM - COMMENT "Running ${CMAKE_CTEST_COMMAND} -V -R \"^${name}$\"" - COMMAND "${CMAKE_CTEST_COMMAND}" -V -R "^${name}$" + COMMENT "Running ${CMAKE_CTEST_COMMAND} -V -R \"^${name}$\" ${test_config_options}" + COMMAND "${CMAKE_CTEST_COMMAND}" -V -R "^${name}$" ${test_config_options} ) if(TARGET "${name}") add_dependencies("${name}_check" "${name}")