diff --git a/cmake/FetchGTest.cmake b/cmake/FetchGTest.cmake index 7ad7e90..f3778ae 100644 --- a/cmake/FetchGTest.cmake +++ b/cmake/FetchGTest.cmake @@ -1,17 +1,18 @@ include(FetchContent) function(fetch_gtest) - find_package(GTest QUIET) + FetchContent_Declare( + googletest + URL https://github.com/google/googletest/releases/download/v1.16.0/googletest-1.16.0.tar.gz + URL_HASH MD5=9a75eb2ac97300cdb8b65b1a5833f411 + DOWNLOAD_EXTRACT_TIMESTAMP + FALSE + FIND_PACKAGE_ARGS + NAMES + GTest + ) - if(NOT GTest_FOUND) - message(STATUS "GTest not found locally. Downloading from GitHub...") - - FetchContent_Declare( - googletest GIT_REPOSITORY https://github.com/google/googletest.git GIT_TAG v1.16.0 - ) - - # Prevent overriding parent project's compiler/linker settings on Windows - set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) - FetchContent_MakeAvailable(googletest) - endif() + # Prevent overriding parent project's compiler/linker settings on Windows + set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + FetchContent_MakeAvailable(googletest) endfunction()