2019-05-11 02:52:33 +02:00
|
|
|
include(CTest)
|
2019-05-21 19:49:31 +02:00
|
|
|
file(GLOB sources_tests test_*.cpp)
|
2019-05-11 02:52:33 +02:00
|
|
|
|
|
|
|
find_package(Catch2)
|
|
|
|
if(Catch2_FOUND) # Catch 2.x
|
|
|
|
include(Catch)
|
2019-05-21 19:49:31 +02:00
|
|
|
add_executable(all_tests main.cpp ${sources_tests})
|
2019-05-11 02:52:33 +02:00
|
|
|
target_link_libraries(all_tests Catch2::Catch2 ${PROJECT_NAME}_testlib)
|
|
|
|
target_include_directories(all_tests PRIVATE "/usr/include/catch2")
|
|
|
|
catch_discover_tests(all_tests EXTRA_ARGS "${EXTRA_TEST_ARGS}")
|
|
|
|
else() # Catch 1.x
|
|
|
|
if(EXISTS "/usr/include/catch.hpp")
|
|
|
|
message(STATUS "Catch 1.x found.")
|
|
|
|
foreach(src ${sources_tests})
|
|
|
|
get_filename_component(bin ${src} NAME_WE)
|
2019-05-21 19:49:31 +02:00
|
|
|
add_executable(${bin} main.cpp ${src})
|
2019-05-11 02:52:33 +02:00
|
|
|
target_link_libraries(${bin} ${PROJECT_NAME}_testlib)
|
|
|
|
add_test(${bin} ${bin} "${EXTRA_TEST_ARGS}")
|
|
|
|
endforeach()
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR
|
|
|
|
"Neither Catch 2.x nor Catch 1.x could be found.")
|
|
|
|
endif()
|
|
|
|
endif()
|