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 <alexandru.croitor@qt.io>
bb10
Alexey Edelev 2022-02-08 15:25:52 +01:00
parent d4de57de42
commit 3bee7db419
1 changed files with 8 additions and 2 deletions

View File

@ -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 $<CONFIG>)
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}")