Moved tests.CmakeLists.txt to tests/CmakeLists.txt.

This commit is contained in:
tastytea 2019-05-21 19:49:31 +02:00
parent 721804ab33
commit 74ebc774d8
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
2 changed files with 4 additions and 4 deletions

View File

@ -71,7 +71,7 @@ endif()
if(WITH_TESTS)
add_library(${PROJECT_NAME}_testlib SHARED ${sources})
target_link_libraries(${PROJECT_NAME}_testlib ${COMMON_LIBRARIES})
include(tests.CMakeLists.txt)
add_subdirectory(tests)
endif()
include(packages.CMakeLists.txt)

View File

@ -1,10 +1,10 @@
include(CTest)
file(GLOB sources_tests tests/test_*.cpp)
file(GLOB sources_tests test_*.cpp)
find_package(Catch2)
if(Catch2_FOUND) # Catch 2.x
include(Catch)
add_executable(all_tests tests/main.cpp ${sources_tests})
add_executable(all_tests main.cpp ${sources_tests})
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}")
@ -13,7 +13,7 @@ else() # Catch 1.x
message(STATUS "Catch 1.x found.")
foreach(src ${sources_tests})
get_filename_component(bin ${src} NAME_WE)
add_executable(${bin} tests/main.cpp ${src})
add_executable(${bin} main.cpp ${src})
target_link_libraries(${bin} ${PROJECT_NAME}_testlib)
add_test(${bin} ${bin} "${EXTRA_TEST_ARGS}")
endforeach()