diff --git a/googletest/CMakeLists.txt b/googletest/CMakeLists.txt index 2e5388945f..b2e1ac767a 100644 --- a/googletest/CMakeLists.txt +++ b/googletest/CMakeLists.txt @@ -26,6 +26,13 @@ option( "Build gtest with internal symbols hidden in shared libraries." OFF) +# set(GTEST_BUILD_USING_STD_MODULE ON) +# set(CMAKE_CXX_STANDARD 23) +# set(CMAKE_CXX_EXTENSIONS OFF) +# set(CMAKE_CXX_STANDARD_REQUIRED ON) +# set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD ON) +# set(CMAKE_CXX_SCAN_FOR_MODULES ON) + # Defines pre_project_set_up_hermetic_build() and set_up_hermetic_build(). include(cmake/hermetic_build.cmake OPTIONAL) @@ -120,7 +127,44 @@ include_directories(${gtest_build_include_dirs}) # Google Test libraries. We build them using more strict warnings than what # are used for other targets, to ensure that gtest can be compiled by a user # aggressive about warnings. -cxx_library(gtest "${cxx_strict}" src/gtest-all.cc) + +cxx_library(gtest "${cxx_strict}" + src/gtest-all.cc + # src/gtest.cc + # src/gtest-port.cc + # src/gtest-assertion-result.cc + # src/gtest-death-test.cc + # src/gtest-filepath.cc + # src/gtest-internal-inl.h + # src/gtest-matchers.cc + # src/gtest-port.cc + # src/gtest-printers.cc + # src/gtest-test-part.cc + # src/gtest-typed-test.cc + include/gtest/gtest.h + include/gtest/gtest_pred_impl.h + include/gtest/gtest_prod.h + include/gtest/gtest-assertion-result.h + include/gtest/gtest-death-test.h + include/gtest/gtest-matchers.h + include/gtest/gtest-message.h + include/gtest/gtest-param-test.h + include/gtest/gtest-printers.h + include/gtest/gtest-spi.h + include/gtest/gtest-test-part.h + include/gtest/gtest-typed-test.h + include/gtest/internal/gtest-death-test-internal.h + include/gtest/internal/gtest-filepath.h + include/gtest/internal/gtest-internal.h + include/gtest/internal/gtest-param-util.h + include/gtest/internal/gtest-port-arch.h + include/gtest/internal/gtest-port.h + include/gtest/internal/gtest-string.h + include/gtest/internal/gtest-type-util.h + include/gtest/internal/custom/gtest.h + include/gtest/internal/custom/gtest-port.h + include/gtest/internal/custom/gtest-printers.h + ) set_target_properties(gtest PROPERTIES VERSION ${GOOGLETEST_VERSION}) if(GTEST_HAS_ABSL) target_compile_definitions(gtest PUBLIC GTEST_HAS_ABSL=1) @@ -135,6 +179,11 @@ if(GTEST_HAS_ABSL) re2::re2 ) endif() +if(GTEST_BUILD_USING_STD_MODULE) + message(STATUS GTEST_BUILD_USING_STD_MODULE=${GTEST_BUILD_USING_STD_MODULE}) + target_compile_definitions(gtest PRIVATE GTEST_BUILD_USING_STD_MODULE) +endif() + cxx_library(gtest_main "${cxx_strict}" src/gtest_main.cc) set_target_properties(gtest_main PROPERTIES VERSION ${GOOGLETEST_VERSION}) string(REPLACE ";" "$" dirs "${gtest_build_include_dirs}") diff --git a/googletest/include/gtest/gtest-assertion-result.h b/googletest/include/gtest/gtest-assertion-result.h index 954e7c40f3..069a981255 100644 --- a/googletest/include/gtest/gtest-assertion-result.h +++ b/googletest/include/gtest/gtest-assertion-result.h @@ -38,10 +38,14 @@ #ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_ASSERTION_RESULT_H_ #define GOOGLETEST_INCLUDE_GTEST_GTEST_ASSERTION_RESULT_H_ -#include -#include -#include -#include +#if defined(GTEST_BUILD_USING_STD_MODULE) + import std; +#else + #include + #include + #include + #include +#endif #include "gtest/gtest-message.h" #include "gtest/internal/gtest-port.h" diff --git a/googletest/include/gtest/gtest-matchers.h b/googletest/include/gtest/gtest-matchers.h index 93643dba1d..add42f654c 100644 --- a/googletest/include/gtest/gtest-matchers.h +++ b/googletest/include/gtest/gtest-matchers.h @@ -39,12 +39,16 @@ #ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_MATCHERS_H_ #define GOOGLETEST_INCLUDE_GTEST_GTEST_MATCHERS_H_ -#include -#include -#include -#include -#include -#include +#if defined(GTEST_BUILD_USING_STD_MODULE) + import std; +#else + #include + #include + #include + #include + #include + #include +#endif #include "gtest/gtest-printers.h" #include "gtest/internal/gtest-internal.h" diff --git a/googletest/include/gtest/gtest-message.h b/googletest/include/gtest/gtest-message.h index 448ac6b7ee..deb7995867 100644 --- a/googletest/include/gtest/gtest-message.h +++ b/googletest/include/gtest/gtest-message.h @@ -48,11 +48,15 @@ #ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_MESSAGE_H_ #define GOOGLETEST_INCLUDE_GTEST_GTEST_MESSAGE_H_ -#include -#include -#include -#include -#include +#if defined(GTEST_BUILD_USING_STD_MODULE) + import std; +#else + #include + #include + #include + #include + #include +#endif #include "gtest/internal/gtest-port.h" diff --git a/googletest/include/gtest/gtest-param-test.h b/googletest/include/gtest/gtest-param-test.h index 9e023f96dc..b2e37668f0 100644 --- a/googletest/include/gtest/gtest-param-test.h +++ b/googletest/include/gtest/gtest-param-test.h @@ -174,9 +174,13 @@ TEST_P(DerivedTest, DoesBlah) { #endif // 0 -#include -#include -#include +#if defined(GTEST_BUILD_USING_STD_MODULE) + import std; +#else + #include + #include + #include +#endif #include "gtest/internal/gtest-internal.h" #include "gtest/internal/gtest-param-util.h" // IWYU pragma: export diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h index 048c32db2e..b9aaf7875f 100644 --- a/googletest/include/gtest/gtest-printers.h +++ b/googletest/include/gtest/gtest-printers.h @@ -104,20 +104,24 @@ #ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_PRINTERS_H_ #define GOOGLETEST_INCLUDE_GTEST_GTEST_PRINTERS_H_ -#include -#include -#include -#include -#include // NOLINT -#include -#include -#include -#include -#include -#include -#include -#include -#include +#if defined(GTEST_BUILD_USING_STD_MODULE) + import std; +#else + #include + #include + #include + #include + #include // NOLINT + #include + #include + #include + #include + #include + #include + #include + #include + #include +#endif #ifdef GTEST_HAS_ABSL #include "absl/strings/has_absl_stringify.h" @@ -127,11 +131,15 @@ #include "gtest/internal/gtest-port.h" #if GTEST_INTERNAL_HAS_STD_SPAN -#include // NOLINT +#if !defined(GTEST_BUILD_USING_STD_MODULE) + #include // NOLINT +#endif #endif // GTEST_INTERNAL_HAS_STD_SPAN #if GTEST_INTERNAL_HAS_COMPARE_LIB -#include // NOLINT +#if !defined(GTEST_BUILD_USING_STD_MODULE) + #include // NOLINT +#endif #endif // GTEST_INTERNAL_HAS_COMPARE_LIB namespace testing { diff --git a/googletest/include/gtest/gtest-spi.h b/googletest/include/gtest/gtest-spi.h index c0613b6959..6566b0c964 100644 --- a/googletest/include/gtest/gtest-spi.h +++ b/googletest/include/gtest/gtest-spi.h @@ -33,7 +33,11 @@ #ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_SPI_H_ #define GOOGLETEST_INCLUDE_GTEST_GTEST_SPI_H_ -#include +#if defined(GTEST_BUILD_USING_STD_MODULE) + import std; +#else + #include +#endif #include "gtest/gtest.h" diff --git a/googletest/include/gtest/gtest-test-part.h b/googletest/include/gtest/gtest-test-part.h index 41c8a9a0d0..6ef900a1b8 100644 --- a/googletest/include/gtest/gtest-test-part.h +++ b/googletest/include/gtest/gtest-test-part.h @@ -34,10 +34,14 @@ #ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_TEST_PART_H_ #define GOOGLETEST_INCLUDE_GTEST_GTEST_TEST_PART_H_ -#include -#include -#include -#include +#if defined(GTEST_BUILD_USING_STD_MODULE) + import std; +#else + #include + #include + #include + #include +#endif #include "gtest/internal/gtest-internal.h" #include "gtest/internal/gtest-string.h" diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index 69994ee9dc..fd71dc84c0 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -49,16 +49,20 @@ #ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_H_ #define GOOGLETEST_INCLUDE_GTEST_GTEST_H_ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#if defined(GTEST_BUILD_USING_STD_MODULE) + import std; +#else + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#endif #include "gtest/gtest-assertion-result.h" // IWYU pragma: export #include "gtest/gtest-death-test.h" // IWYU pragma: export diff --git a/googletest/include/gtest/internal/gtest-death-test-internal.h b/googletest/include/gtest/internal/gtest-death-test-internal.h index b363259ec6..ea8807eff0 100644 --- a/googletest/include/gtest/internal/gtest-death-test-internal.h +++ b/googletest/include/gtest/internal/gtest-death-test-internal.h @@ -41,8 +41,12 @@ #include -#include -#include +#if defined(GTEST_BUILD_USING_STD_MODULE) + import std; +#else + #include + #include +#endif #include "gtest/gtest-matchers.h" #include "gtest/internal/gtest-internal.h" diff --git a/googletest/include/gtest/internal/gtest-filepath.h b/googletest/include/gtest/internal/gtest-filepath.h index 6dc47be54a..fe79ce676f 100644 --- a/googletest/include/gtest/internal/gtest-filepath.h +++ b/googletest/include/gtest/internal/gtest-filepath.h @@ -42,8 +42,12 @@ #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_ #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_ -#include -#include +#if defined(GTEST_BUILD_USING_STD_MODULE) + import std; +#else + #include + #include +#endif #include "gtest/internal/gtest-port.h" #include "gtest/internal/gtest-string.h" diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h index 808d89be91..3d8eeea1f0 100644 --- a/googletest/include/gtest/internal/gtest-internal.h +++ b/googletest/include/gtest/internal/gtest-internal.h @@ -48,23 +48,28 @@ #include #endif // GTEST_OS_LINUX -#if GTEST_HAS_EXCEPTIONS -#include -#endif - #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#if defined(GTEST_BUILD_USING_STD_MODULE) + import std; +#else + #if GTEST_HAS_EXCEPTIONS + #include + #endif + + #include + #include + #include + #include + #include + #include + #include + #include + #include +#endif + #include "gtest/gtest-message.h" #include "gtest/internal/gtest-filepath.h" diff --git a/googletest/include/gtest/internal/gtest-param-util.h b/googletest/include/gtest/internal/gtest-param-util.h index a092a86ada..95756c7c64 100644 --- a/googletest/include/gtest/internal/gtest-param-util.h +++ b/googletest/include/gtest/internal/gtest-param-util.h @@ -36,21 +36,25 @@ #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_ #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_ -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#if defined(GTEST_BUILD_USING_STD_MODULE) + import std; +#else + #include + + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#endif #include "gtest/gtest-printers.h" #include "gtest/gtest-test-part.h" diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index f810d06443..baabbb24c3 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -247,6 +247,10 @@ // Int32FromGTestEnv() - parses an int32_t environment variable. // StringFromGTestEnv() - parses a string environment variable. +#if defined(GTEST_BUILD_USING_STD_MODULE) + import std; +#endif + // The definition of GTEST_INTERNAL_CPLUSPLUS_LANG comes first because it can // potentially be used as an #include guard. #if defined(_MSVC_LANG) @@ -285,20 +289,22 @@ #include #include #include - -#include -// #include // Guarded by GTEST_IS_THREADSAFE below -#include -#include -#include -#include -#include -#include -#include -// #include // Guarded by GTEST_IS_THREADSAFE below -#include -#include -#include + +#if !defined(GTEST_BUILD_USING_STD_MODULE) + #include + // #include // Guarded by GTEST_IS_THREADSAFE below + #include + #include + #include + #include + #include + #include + #include + // #include // Guarded by GTEST_IS_THREADSAFE below + #include + #include + #include +#endif #ifndef _WIN32_WCE #include @@ -575,9 +581,11 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // It's this header's responsibility to #include when RTTI // is enabled. +#if !defined(GTEST_BUILD_USING_STD_MODULE) #if GTEST_HAS_RTTI #include #endif +#endif // Determines whether Google Test can use the pthreads library. #ifndef GTEST_HAS_PTHREAD @@ -810,11 +818,13 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; #endif // GTEST_IS_THREADSAFE +#if !defined(GTEST_BUILD_USING_STD_MODULE) #ifdef GTEST_IS_THREADSAFE // Some platforms don't support including these threading related headers. #include // NOLINT #include // NOLINT #endif // GTEST_IS_THREADSAFE +#endif // GTEST_API_ qualifies all symbols that must be exported. The definitions below // are guarded by #ifndef to give embedders a chance to define GTEST_API_ in @@ -2355,7 +2365,9 @@ using StringView = ::absl::string_view; // Otherwise for C++17 and higher use std::string_view for Matcher<> // specializations. #define GTEST_INTERNAL_HAS_STRING_VIEW 1 +#if !defined(GTEST_BUILD_USING_STD_MODULE) #include +#endif namespace testing { namespace internal { using StringView = ::std::string_view; diff --git a/googletest/include/gtest/internal/gtest-string.h b/googletest/include/gtest/internal/gtest-string.h index 7c05b58339..8272e3ffba 100644 --- a/googletest/include/gtest/internal/gtest-string.h +++ b/googletest/include/gtest/internal/gtest-string.h @@ -50,9 +50,13 @@ #include -#include -#include -#include +#if defined(GTEST_BUILD_USING_STD_MODULE) + import std; +#else + #include + #include + #include +#endif #include "gtest/internal/gtest-port.h" diff --git a/googletest/include/gtest/internal/gtest-type-util.h b/googletest/include/gtest/internal/gtest-type-util.h index 78da05316d..8f99f280cb 100644 --- a/googletest/include/gtest/internal/gtest-type-util.h +++ b/googletest/include/gtest/internal/gtest-type-util.h @@ -37,9 +37,13 @@ #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_ #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_ -#include -#include -#include +#if defined(GTEST_BUILD_USING_STD_MODULE) + import std; +#else + #include + #include + #include +#endif #include "gtest/internal/gtest-port.h" diff --git a/googletest/src/gtest-internal-inl.h b/googletest/src/gtest-internal-inl.h index 6a39b93be1..f0881b3f1e 100644 --- a/googletest/src/gtest-internal-inl.h +++ b/googletest/src/gtest-internal-inl.h @@ -41,13 +41,17 @@ #include // For strtoll/_strtoul64/malloc/free. #include // For memmove. -#include -#include -#include -#include -#include -#include -#include +#if defined(GTEST_BUILD_USING_STD_MODULE) + import std; +#else + #include + #include + #include + #include + #include + #include + #include +#endif #include "gtest/internal/gtest-port.h"