diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0d3ab0c2..55e4c8a6 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -20,19 +20,22 @@ SET(CMAKE_BUILD_TYPE DEBUG) ################################################################################ # download and compile GTest ################################################################################ -INCLUDE(ExternalProject) - -# Download from GitHub -INCLUDE(FetchContent) -FetchContent_Declare( - googletest - URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip) - -# For Windows: Prevent overriding the parent project's compiler/linker settings -SET(gtest_force_shared_crt ON CACHE BOOL "" FORCE) -FetchContent_MakeAvailable(googletest) - -INCLUDE(GoogleTest) +find_package(GTest) +if(NOT GTEST_FOUND) + INCLUDE(ExternalProject) + + # Download from GitHub + INCLUDE(FetchContent) + FetchContent_Declare( + googletest + URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip) + + # For Windows: Prevent overriding the parent project's compiler/linker settings + SET(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + FetchContent_MakeAvailable(googletest) + + INCLUDE(GoogleTest) +endif() ################################################################################ # add gtest dependency