diff --git a/Source/ThirdParty/gtest/include/gtest/internal/gtest-port.h b/Source/ThirdParty/gtest/include/gtest/internal/gtest-port.h
index b887e24edcd0..8d5af58bd273 100644
--- a/Source/ThirdParty/gtest/include/gtest/internal/gtest-port.h
+++ b/Source/ThirdParty/gtest/include/gtest/internal/gtest-port.h
@@ -2349,12 +2349,17 @@ using Any = ::absl::any;
 }  // namespace internal
 }  // namespace testing
 #else
+#if !defined(GTEST_INTERNAL_HAS_ANY)
 #ifdef __has_include
 #if __has_include(<any>) && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L && \
     (!defined(_MSC_VER) || GTEST_HAS_RTTI)
 // Otherwise for C++17 and higher use std::any for UniversalPrinter<>
 // specializations.
 #define GTEST_INTERNAL_HAS_ANY 1
+#endif  // __has_include(<any>) && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
+#endif  // __has_include
+#endif  // !defined(GTEST_INTERNAL_HAS_ANY)
+#if GTEST_INTERNAL_HAS_ANY
 #include <any>
 namespace testing {
 namespace internal {
@@ -2363,8 +2368,7 @@ using Any = ::std::any;
 }  // namespace testing
 // The case where absl is configured NOT to alias std::any is not
 // supported.
-#endif  // __has_include(<any>) && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
-#endif  // __has_include
+#endif  // GTEST_INTERNAL_HAS_ANY
 #endif  // GTEST_HAS_ABSL
 
 #ifndef GTEST_INTERNAL_HAS_ANY
@@ -2384,11 +2388,16 @@ inline ::absl::nullopt_t Nullopt() { return ::absl::nullopt; }
 }  // namespace internal
 }  // namespace testing
 #else
+#if !defined(GTEST_INTERNAL_HAS_OPTIONAL)
 #ifdef __has_include
 #if __has_include(<optional>) && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
 // Otherwise for C++17 and higher use std::optional for UniversalPrinter<>
 // specializations.
 #define GTEST_INTERNAL_HAS_OPTIONAL 1
+#endif  // __has_include(<optional>) && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
+#endif  // __has_include
+#endif  // !defined(GTEST_INTERNAL_HAS_OPTIONAL)
+#if GTEST_INTERNAL_HAS_OPTIONAL
 #include <optional>
 namespace testing {
 namespace internal {
@@ -2399,8 +2408,7 @@ inline ::std::nullopt_t Nullopt() { return ::std::nullopt; }
 }  // namespace testing
 // The case where absl is configured NOT to alias std::optional is not
 // supported.
-#endif  // __has_include(<optional>) && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
-#endif  // __has_include
+#endif  // GTEST_INTERNAL_HAS_OPTIONAL
 #endif  // GTEST_HAS_ABSL
 
 #ifndef GTEST_INTERNAL_HAS_OPTIONAL
@@ -2418,11 +2426,17 @@ using StringView = ::absl::string_view;
 }  // namespace internal
 }  // namespace testing
 #else
+#if !defined(GTEST_INTERNAL_HAS_STRING_VIEW)
 #ifdef __has_include
 #if __has_include(<string_view>) && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
 // Otherwise for C++17 and higher use std::string_view for Matcher<>
 // specializations.
 #define GTEST_INTERNAL_HAS_STRING_VIEW 1
+#endif  // __has_include(<string_view>) && GTEST_INTERNAL_CPLUSPLUS_LANG >=
+        // 201703L
+#endif  // __has_include
+#endif  // // !defined(GTEST_INTERNAL_HAS_STRING_VIEW)
+#if GTEST_INTERNAL_HAS_STRING_VIEW
 #include <string_view>
 namespace testing {
 namespace internal {
@@ -2431,9 +2445,7 @@ using StringView = ::std::string_view;
 }  // namespace testing
 // The case where absl is configured NOT to alias std::string_view is not
 // supported.
-#endif  // __has_include(<string_view>) && GTEST_INTERNAL_CPLUSPLUS_LANG >=
-        // 201703L
-#endif  // __has_include
+#endif  // GTEST_INTERNAL_HAS_STRING_VIEW
 #endif  // GTEST_HAS_ABSL
 
 #ifndef GTEST_INTERNAL_HAS_STRING_VIEW
@@ -2452,11 +2464,16 @@ using Variant = ::absl::variant<T...>;
 }  // namespace internal
 }  // namespace testing
 #else
+#if !defined(GTEST_INTERNAL_HAS_VARIANT)
 #ifdef __has_include
 #if __has_include(<variant>) && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
 // Otherwise for C++17 and higher use std::variant for UniversalPrinter<>
 // specializations.
 #define GTEST_INTERNAL_HAS_VARIANT 1
+#endif  // __has_include(<variant>) && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
+#endif  // __has_include
+#endif  // !defined(GTEST_INTERNAL_HAS_VARIANT)
+#if GTEST_INTERNAL_HAS_VARIANT
 #include <variant>
 namespace testing {
 namespace internal {
@@ -2465,8 +2482,7 @@ using Variant = ::std::variant<T...>;
 }  // namespace internal
 }  // namespace testing
 // The case where absl is configured NOT to alias std::variant is not supported.
-#endif  // __has_include(<variant>) && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
-#endif  // __has_include
+#endif  // GTEST_INTERNAL_HAS_VARIANT
 #endif  // GTEST_HAS_ABSL
 
 #ifndef GTEST_INTERNAL_HAS_VARIANT
