From 6284e504b144619411ac41092d53fc8541c84cdb Mon Sep 17 00:00:00 2001
From: Paul Zander <negril.nx@gmail.com>
Date: Tue, 15 Apr 2025 13:48:00 +0200
Subject: [PATCH] system gtest

Signed-off-by: Paul Zander <negril.nx@gmail.com>

diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt
index 418d2255a75..6b5cd31f9b7 100644
--- a/extern/CMakeLists.txt
+++ b/extern/CMakeLists.txt
@@ -77,12 +77,14 @@ if(WITH_LIBMV OR WITH_GTESTS OR (WITH_CYCLES AND WITH_CYCLES_LOGGING))
   if(NOT WITH_SYSTEM_GFLAGS)
     add_subdirectory(gflags)
   endif()
-  add_subdirectory(glog)
+  if(NOT WITH_SYSTEM_GLOG)
+    add_subdirectory(glog)
+  endif()
 endif()
 
-if(WITH_GTESTS)
-  add_subdirectory(gtest)
-  add_subdirectory(gmock)
+if(WITH_GTESTS AND NOT WITH_SYSTEM_GTEST)
+    add_subdirectory(gtest)
+    add_subdirectory(gmock)
 endif()
 
 if(WITH_AUDASPACE AND NOT WITH_SYSTEM_AUDASPACE)
diff --git a/intern/libmv/CMakeLists.txt b/intern/libmv/CMakeLists.txt
index 965d0028020..825c2141f5a 100644
--- a/intern/libmv/CMakeLists.txt
+++ b/intern/libmv/CMakeLists.txt
@@ -34,6 +34,7 @@ if(WITH_LIBMV)
     ${GLOG_INCLUDE_DIRS}
     ../guardedalloc
   )
+  list(REMOVE_DUPLICATES INC)
 
   list(APPEND INC_SYS
     ${EIGEN3_INCLUDE_DIRS}
diff --git a/tests/gtests/testing/CMakeLists.txt b/tests/gtests/testing/CMakeLists.txt
index ff7f6905836..d46b1d65174 100644
--- a/tests/gtests/testing/CMakeLists.txt
+++ b/tests/gtests/testing/CMakeLists.txt
@@ -13,6 +13,7 @@ set(INC
   ${GFLAGS_INCLUDE_DIRS}
   ../../../extern/gtest/include
 )
+list(REMOVE_DUPLICATES INC)
 
 set(INC_SYS
 )
-- 
2.49.0

