feature: include CMAKE_CTEST_ARGUMENTS in CTEST_TEST_TARGET_ALIAS
Since CMake 2, our project has had a custom runtests target at the top-level that just calls ctest with some project-specific options. This allows us to 1) adopt a single workflow across Linux command line, Windows command line, and Windows Visual Studio GUI development, and 2) customize the default behavior of the ctest command.
CMake 3.17 introduced CMAKE_CTEST_ARGUMENTS
(discussed in #20172 (closed) and !4168 (merged)) that would allow us to solve the second requirement above without creating a custom runtests target. However, since different generators name the default test target either test
or RUN_TESTS
, adoption of CMAKE_CTEST_ARGUMENTS
would violate the first requirement.
Would you consider updating the CTEST_TEST_TARGET_ALIAS
to include the CMAKE_CTEST_ARGUMENTS
?
if(CTEST_TEST_TARGET_ALIAS)
add_custom_target(${CTEST_TEST_TARGET_ALIAS}
${CMAKE_CTEST_COMMAND} ${CMAKE_CTEST_ARGUMENTS} ${__conf_types}
USES_TERMINAL
)
endif()
This would allow us to do,
# Add project-specific options to the autogenerated test or RUN_TESTS target
set( CMAKE_CTEST_ARGUMENTS -T Test --no-compress-output )
# Alias the generator-specific test (Makefile) and RUN_TESTS (Visual Studio)
# targets into a common, cross-platform, runtests target.
set( CTEST_TEST_TARGET_ALIAS runtests )
include( CTest )
Alternatively, since CTEST_TEST_TARGET_ALIAS
seems to be an undocumented feature, how would you recommend accomplishing the two requirements above?