Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions cmake/FetchGTest.cmake
Original file line number Diff line number Diff line change
@@ -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()