Skip to content

Commit

Permalink
Search for Catch2 with find_package() first
Browse files Browse the repository at this point in the history
 * And if not found, download it with the FetchContent module.
  • Loading branch information
mymedia2 committed Jun 17, 2023
1 parent 3f0ca7b commit c94d06e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,13 @@ if(EXPECTED_BUILD_TESTS)
set(CATCH_INSTALL_HELPERS OFF)
set(CATCH_BUILD_TESTING OFF)
set(CATCH_INSTALL_DOCS OFF)
FetchContent_Declare(Catch2 URL
https://github.com/catchorg/Catch2/archive/v2.13.10.zip)
FetchContent_MakeAvailable(Catch2)

find_package(Catch2)
if (NOT Catch2_FOUND)
FetchContent_Declare(Catch2 URL
https://github.com/catchorg/Catch2/archive/v2.13.10.zip)
FetchContent_MakeAvailable(Catch2)
endif()

file(GLOB test-sources CONFIGURE_DEPENDS tests/*.cpp)
list(FILTER test-sources EXCLUDE REGEX "tests/test.cpp")
Expand Down

0 comments on commit c94d06e

Please sign in to comment.