Simplify testing. No need to use CMake testing module for this.

This commit is contained in:
Jacob 2024-05-14 20:33:05 +02:00
parent 93b5a57c35
commit 1458273912

View file

@ -70,8 +70,6 @@ if (NOT WIN32 AND NOT APPLE)
endif() endif()
if (CMAKE_BUILD_TYPE STREQUAL "Debug") if (CMAKE_BUILD_TYPE STREQUAL "Debug")
enable_testing()
find_package(Catch2 3 REQUIRED) find_package(Catch2 3 REQUIRED)
add_executable(${PROJECT_NAME}_test add_executable(${PROJECT_NAME}_test
@ -86,17 +84,12 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
Catch2::Catch2WithMain Catch2::Catch2WithMain
) )
include(CTest)
include(Catch)
catch_discover_tests(${PROJECT_NAME}_test)
add_custom_command( add_custom_command(
TARGET ${PROJECT_NAME}_test TARGET ${PROJECT_NAME}_test
COMMENT "Run tests" COMMENT "Run tests"
POST_BUILD POST_BUILD
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure --rerun-failed -C COMMAND ${PROJECT_NAME}_test
$<CONFIGURATION> -R "^${PROJECT_NAME}_test$"
) )
endif() endif()