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

28 lines
959 B
CMake
Raw Permalink Normal View History

2019-04-14 04:11:17 +02:00
include(CTest)
2019-08-14 00:15:04 +02:00
file(GLOB_RECURSE sources_tests test_*.cpp)
configure_file("test.gif" "${CMAKE_CURRENT_BINARY_DIR}" COPYONLY)
2019-04-14 04:11:17 +02:00
find_package(Catch2)
2019-08-14 00:15:04 +02:00
if(Catch2_FOUND) # Catch 2.x
2019-04-14 04:11:17 +02:00
include(Catch)
add_executable(all_tests main.cpp ${sources_tests})
2019-08-14 00:15:04 +02:00
target_link_libraries(all_tests PRIVATE ${PROJECT_NAME} Catch2::Catch2)
2019-04-14 04:11:17 +02:00
target_include_directories(all_tests PRIVATE "/usr/include/catch2")
catch_discover_tests(all_tests EXTRA_ARGS "${EXTRA_TEST_ARGS}")
2019-08-14 00:15:04 +02:00
else() # Catch 1.x
2019-04-14 04:11:17 +02:00
if(EXISTS "/usr/include/catch.hpp")
message(STATUS "Catch 1.x found.")
foreach(src ${sources_tests})
get_filename_component(bin ${src} NAME_WE)
2019-06-10 18:33:44 +02:00
add_executable(${bin} main.cpp ${src})
2019-08-14 00:15:04 +02:00
target_link_libraries(${bin} PRIVATE ${PROJECT_NAME})
add_test(${bin} ${bin} "${EXTRA_TEST_ARGS}")
2019-04-14 04:11:17 +02:00
endforeach()
else()
message(FATAL_ERROR
"Neither Catch 2.x nor Catch 1.x could be found.")
endif()
endif()