This repository has been archived on 2020-05-10. You can view files and clone it, but cannot push or open issues or pull requests.
mastodon-cpp/tests.CMakeLists.txt
tastytea a1083b5c18
All checks were successful
the build was successful
Changed CMAKE_PROJECT_NAME to PROJECT_NAME.
2019-04-14 04:38:59 +02:00

25 lines
808 B
Plaintext

include(CTest)
file(GLOB sources_tests tests/test_*.cpp)
find_package(Catch2)
if(Catch2_FOUND) # Catch 2.x
include(Catch)
add_executable(all_tests tests/main.cpp ${sources_tests})
target_link_libraries(all_tests ${PROJECT_NAME} Catch2::Catch2)
target_include_directories(all_tests PRIVATE "/usr/include/catch2")
catch_discover_tests(all_tests)
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)
add_executable(${bin} tests/main.cpp ${src})
target_link_libraries(${bin} ${PROJECT_NAME})
add_test(${bin} ${bin})
endforeach()
else()
message(FATAL_ERROR
"Neither Catch 2.x nor Catch 1.x could be found.")
endif()
endif()