diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 2e2baaa..78fd327 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -5,11 +5,16 @@ file(COPY "test.epub3" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) find_package(Catch2 CONFIG) -if(Catch2_FOUND) # Catch 2.x +if(Catch2_FOUND) # Catch 2.x / 3.x include(Catch) add_executable(all_tests main.cpp ${sources_tests}) - target_link_libraries(all_tests - PRIVATE Catch2::Catch2 ${PROJECT_NAME}_lib) + if(TARGET Catch2::Catch2WithMain) # Catch 3.x + target_link_libraries(all_tests + PRIVATE Catch2::Catch2WithMain ${PROJECT_NAME}) + else() # Catch 2.x + target_link_libraries(all_tests + PRIVATE Catch2::Catch2 ${PROJECT_NAME}) + endif() target_include_directories(all_tests PRIVATE "/usr/include/catch2") catch_discover_tests(all_tests EXTRA_ARGS "${EXTRA_TEST_ARGS}") else() # Catch 1.x diff --git a/tests/main.cpp b/tests/main.cpp index e48147e..c81b34b 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -1,3 +1,8 @@ #define CATCH_CONFIG_MAIN -#include +// catch 3 does not have catch.hpp anymore +#if __has_include() +# include +#else +# include +#endif diff --git a/tests/test_helpers.cpp b/tests/test_helpers.cpp index 97454bb..6fa28d9 100644 --- a/tests/test_helpers.cpp +++ b/tests/test_helpers.cpp @@ -1,7 +1,12 @@ #include "fs-compat.hpp" #include "helpers.hpp" -#include +// catch 3 does not have catch.hpp anymore +#if __has_include() +# include +#else +# include +#endif #include #include diff --git a/tests/test_search_epub.cpp b/tests/test_search_epub.cpp index b28e562..e796882 100644 --- a/tests/test_search_epub.cpp +++ b/tests/test_search_epub.cpp @@ -2,7 +2,12 @@ #include "options.hpp" #include "search.hpp" -#include +// catch 3 does not have catch.hpp anymore +#if __has_include() +# include +#else +# include +#endif #include #include diff --git a/tests/test_search_helpers.cpp b/tests/test_search_helpers.cpp index 4df6764..ea5e829 100644 --- a/tests/test_search_helpers.cpp +++ b/tests/test_search_helpers.cpp @@ -2,7 +2,12 @@ #include "fs-compat.hpp" #include "search.hpp" -#include +// catch 3 does not have catch.hpp anymore +#if __has_include() +# include +#else +# include +#endif #include #include diff --git a/tests/test_search_zip.cpp b/tests/test_search_zip.cpp index d616600..825392b 100644 --- a/tests/test_search_zip.cpp +++ b/tests/test_search_zip.cpp @@ -2,7 +2,12 @@ #include "options.hpp" #include "search.hpp" -#include +// catch 3 does not have catch.hpp anymore +#if __has_include() +# include +#else +# include +#endif #include #include diff --git a/tests/test_zip.cpp b/tests/test_zip.cpp index ad9ede4..155c993 100644 --- a/tests/test_zip.cpp +++ b/tests/test_zip.cpp @@ -1,7 +1,12 @@ #include "fs-compat.hpp" #include "zip.hpp" -#include +// catch 3 does not have catch.hpp anymore +#if __has_include() +# include +#else +# include +#endif #include #include