README.md (googletest-release-1.11.0) | : | README.md (googletest-release-1.12.0) | ||
---|---|---|---|---|
skipping to change at line 28 | skipping to change at line 28 | |||
the compiler environment of your choice. You can either build GoogleTest as a | the compiler environment of your choice. You can either build GoogleTest as a | |||
standalone project or it can be incorporated into an existing CMake build for | standalone project or it can be incorporated into an existing CMake build for | |||
another project. | another project. | |||
#### Standalone CMake Project | #### Standalone CMake Project | |||
When building GoogleTest as a standalone project, the typical workflow starts | When building GoogleTest as a standalone project, the typical workflow starts | |||
with | with | |||
``` | ``` | |||
git clone https://github.com/google/googletest.git -b release-1.10.0 | git clone https://github.com/google/googletest.git -b release-1.11.0 | |||
cd googletest # Main directory of the cloned repository. | cd googletest # Main directory of the cloned repository. | |||
mkdir build # Create a directory to hold the build output. | mkdir build # Create a directory to hold the build output. | |||
cd build | cd build | |||
cmake .. # Generate native build scripts for GoogleTest. | cmake .. # Generate native build scripts for GoogleTest. | |||
``` | ``` | |||
The above command also includes GoogleMock by default. And so, if you want to | The above command also includes GoogleMock by default. And so, if you want to | |||
build only GoogleTest, you should replace the last command with | build only GoogleTest, you should replace the last command with | |||
``` | ``` | |||
skipping to change at line 97 | skipping to change at line 97 | |||
The last of the above methods is implemented with a small piece of CMake code | The last of the above methods is implemented with a small piece of CMake code | |||
that downloads and pulls the GoogleTest code into the main build. | that downloads and pulls the GoogleTest code into the main build. | |||
Just add to your `CMakeLists.txt`: | Just add to your `CMakeLists.txt`: | |||
```cmake | ```cmake | |||
include(FetchContent) | include(FetchContent) | |||
FetchContent_Declare( | FetchContent_Declare( | |||
googletest | googletest | |||
# Specify the commit you depend on and update it regularly. | # Specify the commit you depend on and update it regularly. | |||
URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6 c30cc3591e5.zip | URL https://github.com/google/googletest/archive/e2239ee6043f73722e7aa812a459f 54a28552929.zip | |||
) | ) | |||
# For Windows: Prevent overriding the parent project's compiler/linker settings | # For Windows: Prevent overriding the parent project's compiler/linker settings | |||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) | set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) | |||
FetchContent_MakeAvailable(googletest) | FetchContent_MakeAvailable(googletest) | |||
# Now simply link against gtest or gtest_main as needed. Eg | # Now simply link against gtest or gtest_main as needed. Eg | |||
add_executable(example example.cpp) | add_executable(example example.cpp) | |||
target_link_libraries(example gtest_main) | target_link_libraries(example gtest_main) | |||
add_test(NAME example_test COMMAND example) | add_test(NAME example_test COMMAND example) | |||
``` | ``` | |||
skipping to change at line 206 | skipping to change at line 206 | |||
macro of the same name will clash if you `#include` both definitions. In case a | macro of the same name will clash if you `#include` both definitions. In case a | |||
GoogleTest macro clashes with another library, you can force GoogleTest to | GoogleTest macro clashes with another library, you can force GoogleTest to | |||
rename its macro to avoid the conflict. | rename its macro to avoid the conflict. | |||
Specifically, if both GoogleTest and some other code define macro FOO, you can | Specifically, if both GoogleTest and some other code define macro FOO, you can | |||
add | add | |||
-DGTEST_DONT_DEFINE_FOO=1 | -DGTEST_DONT_DEFINE_FOO=1 | |||
to the compiler flags to tell GoogleTest to change the macro's name from `FOO` | to the compiler flags to tell GoogleTest to change the macro's name from `FOO` | |||
to `GTEST_FOO`. Currently `FOO` can be `FAIL`, `SUCCEED`, or `TEST`. For | to `GTEST_FOO`. Currently `FOO` can be `ASSERT_EQ`, `ASSERT_FALSE`, `ASSERT_GE`, | |||
`ASSERT_GT`, `ASSERT_LE`, `ASSERT_LT`, `ASSERT_NE`, `ASSERT_TRUE`, | ||||
`EXPECT_FALSE`, `EXPECT_TRUE`, `FAIL`, `SUCCEED`, `TEST`, or `TEST_F`. For | ||||
example, with `-DGTEST_DONT_DEFINE_TEST=1`, you'll need to write | example, with `-DGTEST_DONT_DEFINE_TEST=1`, you'll need to write | |||
GTEST_TEST(SomeTest, DoesThis) { ... } | GTEST_TEST(SomeTest, DoesThis) { ... } | |||
instead of | instead of | |||
TEST(SomeTest, DoesThis) { ... } | TEST(SomeTest, DoesThis) { ... } | |||
in order to define a test. | in order to define a test. | |||
End of changes. 3 change blocks. | ||||
3 lines changed or deleted | 5 lines changed or added |