This is the legacy fix for https://github.com/google/googletest/issues/4731, and to prevent similar breakages in the future with other flags.
The modern fix will be handled separately.
PiperOrigin-RevId: 953333662
Change-Id: I7c58b0123170878f0fe6909cabd5decc922b38f1
The alternate implementation based on ABSL_FLAG() already does this internally, so this resolves the inconsistency.
Fixes: #4897
PiperOrigin-RevId: 952840499
Change-Id: I7b8f61d2e9a97ffcd3db091abc373c9d9b48db79
In the past, GoogleTest could not set this flag unconditionally as it
would break CUDA on CMake versions older than 3.13. As the project now
requires at least CMake 3.16, it's safe to enable and finally prefer
-pthread to -lpthread.
This does not make any difference on systems with glibc 2.34 as newer,
as libpthread is part of libc now.
Properly fixes#2482
The INSTALL_INTERFACE include directory was written as
$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}, which unconditionally
prepends the install prefix. When CMAKE_INSTALL_INCLUDEDIR is an
absolute path, the exported GTestTargets.cmake ends up with an invalid
doubled path such as "/usr/local//usr/local/include", and find_package
consumers fail at configure time with "Imported target includes
non-existent path".
Relative paths inside $<INSTALL_INTERFACE:...> are already interpreted
relative to the installation prefix, so the explicit $<INSTALL_PREFIX>/
prefix is redundant for relative values and wrong for absolute ones.
Dropping it keeps the exported path identical for relative values
(${_IMPORT_PREFIX}/include) and uses absolute values as-is.
Fixes#4817
Actions can now be implicitly constructed from zero-argument callables. There is no need to create wrapper objects using InvokeWithoutArgs().
PiperOrigin-RevId: 949656497
Change-Id: Ida2bc38e446e7b33aaf185ec593caf2a1959138e
The fallback check GTEST_INTERNAL_HAS_INCLUDE(<compare>) && C++20 causes build failures on Android NDK 24 which has the header but lacks the full comparison operators needed by PrintTo. The feature test macro __cpp_lib_three_way_comparison is the reliable indicator.
Fixes#4933
Since we can't directly depend on proto headers, we rely on ADL + proto headers being included by calling code for this matcher to choose the right overload of `DynamicCastMessage`.
PiperOrigin-RevId: 940593408
Change-Id: I7374aed3c5cfe61a183d28ea02e6583ab340f647
PR https://github.com/google/googletest/pull/3940 added COMPILE_PDB_OUTPUT_DIRECTORY
without updating the install command to accommodate the two PDB properties.
COMPILE_PDB_* and PDB_* properties are two distinct properties that affect static
(COMPILE_PDB_*) and shared (PDB_*) separately.
This commit adds cmake install rule for both types (optionally) to install when available
Protobuf messages have a custom dynamic_cast, for when RTTI is not available on the messages.
PiperOrigin-RevId: 933270097
Change-Id: Iaeb50bce3fe1b746306a7507ab1985b111c03416
In particular this automatically gives us support for examples like the
following:
using SomeFn = absl::AnyInvocable<R(Args...) const>;
MockFunction<SomeFn> some_fn;
PiperOrigin-RevId: 921303527
Change-Id: I19bf59671781e85db65cc20c0d6ea10b056c528a
Subsequences are defined as: "a subsequence of a given sequence is a sequence that can be derived from the given sequence by deleting some or no elements without changing the order of the remaining elements."
See: https://en.wikipedia.org/wiki/Subsequence
This new matcher checks if a container contains elements that match a given sequence of matchers in the specified order, but not necessarily contiguously.
The implementation is very similar to other matchers like ElementsAre or Contains.
PiperOrigin-RevId: 918323422
Change-Id: I56d7ebbe6f81038c93546ef7585db59eea5dbd57
This uses the environment variables as the default value for the command line argument, so this is not a breaking change to most reasonable existing use cases. This *is* a breaking change if a process expects changes to the sharding environment variables to be visible after parsing the command line arguments.
The motivation for this is that some environments do not support environment variables, which prevents the usage of test sharding. These environments also run on simulators and other slow hardware, where sharding is especially important. I've tried a few other things, like hacking together a fake implementation of `getenv`/`setenv`, but this is a pretty unreliable approach on the platform in question.
This also seems like an improvement in consistency to me. Currently, other test selection mechanisms (e.g. filtering, shuffling, repeat), `use arguments (or at least have command line arguments as an option), while as far as I can tell, sharding is the only mechanism which can *only* be specified with environment variables.
PiperOrigin-RevId: 892324928
Change-Id: I5cf814e46e16072e7c160e54c426b02300fe712b
DieInCRTDebugElse12() is only used inside a #ifdef _DEBUG block. Put
its definition inside a #ifdef _DEBUG block, too, otherwise we get a
"defined but not used [-Wunused-function]" warning under MinGW GCC.
PiperOrigin-RevId: 891795658
Change-Id: Ic9109eebc354dd20b2a5430794f491c9b451931f
Add an alternative implementation of the Notification class for MinGW
using a Windows manual-reset event object.
GCC version < 13 in MinGW, if configured with the win32 thread model
(with the --enable-threads=win32 configure option), does not implement
std::mutex and std::condition_variable in the <mutex> and
<condition_variable> headers. So the current implementation of the
Notification class, which uses std::mutex and std::condition_variable,
has compilation errors. Windows has a synchronization object called a
manual-reset event object that behaves just like the Notification class.
So we can easily implement the Notification class using a Windows
manual-reset event object.
This GCC issue is fixed in GCC 13. See
https://gcc.gnu.org/gcc-13/changes.html#windows. This alternative
implementation of Notification should be removed when GoogleTest
requires GCC version >= 13 in MinGW.
Fixes https://github.com/google/googletest/issues/4031 and
https://github.com/google/googletest/issues/4464.
PiperOrigin-RevId: 888752598
Change-Id: I69e01b2e7953e1fe72d87b6d0804c7a8a8d0e740
This is needed for ranges such as [`std::ranges::subrange`](https://en.cppreference.com/w/cpp/ranges/subrange.html) that don't expose the typical typedefs.
PiperOrigin-RevId: 879124865
Change-Id: Ie89e6ff249ee861d1b2d880079dc162bb9801679