diff --git a/unit_tests/CMakeLists.txt b/unit_tests/CMakeLists.txt index 5984524fdc8c596641e505897d16e12de78024cc..6bd1a89d64754e8a41e7032632a9a5449f254ad4 100644 --- a/unit_tests/CMakeLists.txt +++ b/unit_tests/CMakeLists.txt @@ -1,12 +1,19 @@ -Include(FetchContent) +find_package(Catch2 REQUIRED) -FetchContent_Declare( - Catch2 - GIT_REPOSITORY https://github.com/catchorg/Catch2.git - GIT_TAG v3.7.1 # or a later release -) +if(NOT Catch2_FOUND) + message(STATUS "Catch2 not found in system, retrieving from git") + Include(FetchContent) -FetchContent_MakeAvailable(Catch2) + FetchContent_Declare( + Catch2 + GIT_REPOSITORY https://github.com/catchorg/Catch2.git + GIT_TAG devel # or a later release + ) + + FetchContent_MakeAvailable(Catch2) +else() + message(STATUS "Found system Catch2 version ${Catch2_VERSION}") +endif() file(GLOB_RECURSE src_files "*.cpp")