tastytea
2fb329a302
Some checks failed
continuous-integration/drone/push Build is failing
* Compile a library again. * Made CMake recipes modular. * Added xdgcfgConfig.cmake. * Added pkg-config file. * Updated readme.
27 lines
935 B
CMake
27 lines
935 B
CMake
include(CTest)
|
|
file(GLOB sources_tests test_*.cpp)
|
|
|
|
find_package(Catch2 CONFIG)
|
|
if(Catch2_FOUND) # Catch 2.x
|
|
include(Catch)
|
|
add_executable(all_tests main.cpp ${sources_tests})
|
|
target_link_libraries(all_tests Catch2::Catch2 xdgcfg)
|
|
target_include_directories(all_tests
|
|
PRIVATE "../include" "/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)
|
|
add_executable(${bin} main.cpp ${src})
|
|
target_include_directories(${bin} PRIVATE "../include")
|
|
target_link_libraries(${bin} xdgcfg)
|
|
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()
|