From dcb9ccca903f64faaf066e7e19595a0220196fd7 Mon Sep 17 00:00:00 2001 From: Fabrice de Gans Date: Sun, 24 Nov 2024 12:39:10 -0800 Subject: [PATCH] [gtest] Use googletest as a submodule (#1373) Some Linux distributions use a hermetic build environment to build. This resulted in issues with `FetchContent` attempting to download googletest at configure time. This fixes the issue by integrating googletest as a git submodule instead of downloading it at configure time. --- .gitmodules | 3 +++ CMakeLists.txt | 9 ++------- third_party/googletest | 1 + 3 files changed, 6 insertions(+), 7 deletions(-) create mode 160000 third_party/googletest diff --git a/.gitmodules b/.gitmodules index 2539f20c..b6273b6f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,3 +2,6 @@ path = win32-deps url = https://github.com/visualboyadvance-m/win32-deps.git branch = master +[submodule "third_party/googletest"] + path = third_party/googletest + url = https://github.com/google/googletest.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 2416cede..b0d5584a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,14 +90,9 @@ endif() # Configure gtest if(BUILD_TESTING) - FetchContent_Declare(googletest - URL https://github.com/google/googletest/archive/2d16ed055d09c3689d44b272adc097393de948a0.zip - EXCLUDE_FROM_ALL - ) - set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) - FetchContent_MakeAvailable(googletest) - + set(INSTALL_GTEST OFF CACHE BOOL "" FORCE) + add_subdirectory(./third_party/googletest) include(GoogleTest) endif() diff --git a/third_party/googletest b/third_party/googletest new file mode 160000 index 00000000..b514bdc8 --- /dev/null +++ b/third_party/googletest @@ -0,0 +1 @@ +Subproject commit b514bdc898e2951020cbdca1304b75f5950d1f59