From 9f845321de3bdd2b840c42b977c1c092ac553cc2 Mon Sep 17 00:00:00 2001
From: Nicolas Graves <ngraves@ngraves.fr>
Date: Fri, 21 Feb 2025 12:05:59 +0100
Subject: [PATCH] tests/CMakeLists.txt: Find googletest package from inputs

---
 tests/CMakeLists.txt | 29 +----------------------------
 1 file changed, 1 insertion(+), 28 deletions(-)

diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index dfab76e0..16a51b0b 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -48,35 +48,8 @@ if (FAISS_ENABLE_PYTHON)
   target_link_libraries(faiss_test PUBLIC faiss_example_external_module)
 endif()
 
-include(FetchContent)
-FetchContent_Declare(
-  googletest
-  GIT_REPOSITORY https://github.com/google/googletest.git
-  GIT_TAG 58d77fa8070e8cec2dc1ed015d66b454c8d78850 # release-1.12.1
-  OVERRIDE_FIND_PACKAGE)
-set(BUILD_GMOCK CACHE BOOL OFF)
-set(INSTALL_GTEST CACHE BOOL OFF)
-FetchContent_MakeAvailable(googletest)
-
-if(NOT EXISTS ${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/gtest-config.cmake
-   AND NOT EXISTS ${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/GTestConfig.cmake)
-  file(
-    WRITE ${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/gtest-config.cmake
-    [=[
-include(CMakeFindDependencyMacro)
-find_dependency(googletest)
-if(NOT TARGET GTest::GTest)
-  add_library(GTest::GTest INTERFACE IMPORTED)
-  target_link_libraries(GTest::GTest INTERFACE GTest::gtest)
-endif()
-if(NOT TARGET GTest::Main)
-  add_library(GTest::Main INTERFACE IMPORTED)
-  target_link_libraries(GTest::Main INTERFACE GTest::gtest_main)
-endif()
-]=])
-endif()
-
 find_package(OpenMP REQUIRED)
+find_package(GTest REQUIRED)
 find_package(GTest CONFIG REQUIRED)
 
 target_link_libraries(faiss_test PRIVATE
-- 
2.48.1

