2019-01-01 16:46:17 +01:00
|
|
|
if(WITH_TESTS)
|
2019-01-01 17:35:14 +01:00
|
|
|
find_package(Catch2)
|
|
|
|
if(Catch2_FOUND)
|
|
|
|
set(MYCATCH, Catch2::Catch2)
|
|
|
|
else()
|
|
|
|
set(MYCATCH, "")
|
|
|
|
endif()
|
2019-01-01 16:46:17 +01:00
|
|
|
include(CTest)
|
|
|
|
|
|
|
|
file(GLOB sources_tests src/tests/test_*.cpp)
|
|
|
|
foreach(src ${sources_tests})
|
|
|
|
get_filename_component(bin ${src} NAME_WE)
|
|
|
|
add_executable(${bin} src/tests/main.cpp ${src})
|
2019-01-01 17:35:14 +01:00
|
|
|
target_link_libraries(${bin} ${CMAKE_PROJECT_NAME} ${MYCATCH})
|
|
|
|
target_include_directories(${bin} PRIVATE "/usr/include/catch2")
|
2019-01-01 16:46:17 +01:00
|
|
|
add_test(${bin} ${bin})
|
|
|
|
endforeach()
|
|
|
|
endif()
|