Skip to content

Commit 7b63972

Browse files
author
Jinzhi Chen
committed
update release130.22
1 parent 44ae042 commit 7b63972

File tree

147 files changed

+10811
-8172
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+10811
-8172
lines changed

include/googletest/CMakeLists.txt

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
########################################################################
2+
# Note: CMake support is community-based. The maintainers do not use CMake
3+
# internally.
4+
#
25
# CMake build script for Google Test.
36
#
47
# To run the tests for Google Test itself on Linux, use 'make test' or
@@ -40,13 +43,17 @@ endif()
4043
# as ${gtest_SOURCE_DIR} and to the root binary directory as
4144
# ${gtest_BINARY_DIR}.
4245
# Language "C" is required for find_package(Threads).
46+
47+
# Project version:
48+
4349
if (CMAKE_VERSION VERSION_LESS 3.0)
4450
project(gtest CXX C)
51+
set(PROJECT_VERSION ${GOOGLETEST_VERSION})
4552
else()
4653
cmake_policy(SET CMP0048 NEW)
4754
project(gtest VERSION ${GOOGLETEST_VERSION} LANGUAGES CXX C)
4855
endif()
49-
cmake_minimum_required(VERSION 3.0)
56+
5057

5158
if (POLICY CMP0063) # Visibility
5259
cmake_policy(SET CMP0063 NEW)
@@ -93,7 +100,7 @@ if (INSTALL_GTEST)
93100
set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated" CACHE INTERNAL "")
94101
set(cmake_files_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${cmake_package_name}")
95102
set(version_file "${generated_dir}/${cmake_package_name}ConfigVersion.cmake")
96-
write_basic_package_version_file(${version_file} COMPATIBILITY AnyNewerVersion)
103+
write_basic_package_version_file(${version_file} VERSION ${GOOGLETEST_VERSION} COMPATIBILITY AnyNewerVersion)
97104
install(EXPORT ${targets_export_name}
98105
NAMESPACE ${cmake_package_name}::
99106
DESTINATION ${cmake_files_install_dir})
@@ -110,18 +117,6 @@ set(gtest_build_include_dirs
110117
"${gtest_SOURCE_DIR}")
111118
include_directories(${gtest_build_include_dirs})
112119

113-
# Summary of tuple support for Microsoft Visual Studio:
114-
# Compiler version(MS) version(cmake) Support
115-
# ---------- ----------- -------------- -----------------------------
116-
# <= VS 2010 <= 10 <= 1600 Use Google Tests's own tuple.
117-
# VS 2012 11 1700 std::tr1::tuple + _VARIADIC_MAX=10
118-
# VS 2013 12 1800 std::tr1::tuple
119-
# VS 2015 14 1900 std::tuple
120-
# VS 2017 15 >= 1910 std::tuple
121-
if (MSVC AND MSVC_VERSION EQUAL 1700)
122-
add_definitions(/D _VARIADIC_MAX=10)
123-
endif()
124-
125120
########################################################################
126121
#
127122
# Defines the gtest & gtest_main libraries. User tests should link
@@ -187,13 +182,26 @@ if (gtest_build_tests)
187182
# 'make test' or ctest.
188183
enable_testing()
189184

185+
if (WIN32)
186+
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/RunTest.ps1"
187+
CONTENT
188+
"$project_bin = \"${CMAKE_BINARY_DIR}/bin/$<CONFIG>\"
189+
$env:Path = \"$project_bin;$env:Path\"
190+
& $args")
191+
elseif (MINGW OR CYGWIN)
192+
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/RunTest.ps1"
193+
CONTENT
194+
"$project_bin = (cygpath --windows ${CMAKE_BINARY_DIR}/bin)
195+
$env:Path = \"$project_bin;$env:Path\"
196+
& $args")
197+
endif()
198+
190199
############################################################
191200
# C++ tests built with standard compiler flags.
192201

193202
cxx_test(googletest-death-test-test gtest_main)
194203
cxx_test(gtest_environment_test gtest)
195204
cxx_test(googletest-filepath-test gtest_main)
196-
cxx_test(googletest-linked-ptr-test gtest_main)
197205
cxx_test(googletest-listener-test gtest_main)
198206
cxx_test(gtest_main_unittest gtest_main)
199207
cxx_test(googletest-message-test gtest_main)
@@ -217,6 +225,8 @@ if (gtest_build_tests)
217225
test/gtest-typed-test2_test.cc)
218226
cxx_test(gtest_unittest gtest_main)
219227
cxx_test(gtest-unittest-api_test gtest)
228+
cxx_test(gtest_skip_in_environment_setup_test gtest_main)
229+
cxx_test(gtest_skip_test gtest_main)
220230

221231
############################################################
222232
# C++ tests built with non-standard compiler flags.
@@ -250,27 +260,14 @@ if (gtest_build_tests)
250260
PROPERTIES
251261
COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1")
252262

253-
if (NOT MSVC OR MSVC_VERSION LESS 1600) # 1600 is Visual Studio 2010.
254-
# Visual Studio 2010, 2012, and 2013 define symbols in std::tr1 that
255-
# conflict with our own definitions. Therefore using our own tuple does not
256-
# work on those compilers.
257-
cxx_library(gtest_main_use_own_tuple "${cxx_use_own_tuple}"
258-
src/gtest-all.cc src/gtest_main.cc)
259-
260-
cxx_test_with_flags(googletest-tuple-test "${cxx_use_own_tuple}"
261-
gtest_main_use_own_tuple test/googletest-tuple-test.cc)
262-
263-
cxx_test_with_flags(gtest_use_own_tuple_test "${cxx_use_own_tuple}"
264-
gtest_main_use_own_tuple
265-
test/googletest-param-test-test.cc test/googletest-param-test2-test.cc)
266-
endif()
267-
268263
############################################################
269264
# Python tests.
270265

271266
cxx_executable(googletest-break-on-failure-unittest_ test gtest)
272267
py_test(googletest-break-on-failure-unittest)
273268

269+
py_test(gtest_skip_environment_check_output_test)
270+
274271
# Visual Studio .NET 2003 does not support STL with exceptions disabled.
275272
if (NOT MSVC OR MSVC_VERSION GREATER 1310) # 1310 is Visual Studio .NET 2003
276273
cxx_executable_with_flags(

include/googletest/README.md

Lines changed: 65 additions & 162 deletions
Original file line numberDiff line numberDiff line change
@@ -6,48 +6,7 @@ To build Google Test and your tests that use it, you need to tell your build
66
system where to find its headers and source files. The exact way to do it
77
depends on which build system you use, and is usually straightforward.
88

9-
#### Build
10-
11-
Suppose you put Google Test in directory `${GTEST_DIR}`. To build it, create a
12-
library build target (or a project as called by Visual Studio and Xcode) to
13-
compile
14-
15-
${GTEST_DIR}/src/gtest-all.cc
16-
17-
with `${GTEST_DIR}/include` in the system header search path and `${GTEST_DIR}`
18-
in the normal header search path. Assuming a Linux-like system and gcc,
19-
something like the following will do:
20-
21-
g++ -isystem ${GTEST_DIR}/include -I${GTEST_DIR} \
22-
-pthread -c ${GTEST_DIR}/src/gtest-all.cc
23-
ar -rv libgtest.a gtest-all.o
24-
25-
(We need `-pthread` as Google Test uses threads.)
26-
27-
Next, you should compile your test source file with `${GTEST_DIR}/include` in
28-
the system header search path, and link it with gtest and any other necessary
29-
libraries:
30-
31-
g++ -isystem ${GTEST_DIR}/include -pthread path/to/your_test.cc libgtest.a \
32-
-o your_test
33-
34-
As an example, the make/ directory contains a Makefile that you can use to build
35-
Google Test on systems where GNU make is available (e.g. Linux, Mac OS X, and
36-
Cygwin). It doesn't try to build Google Test's own tests. Instead, it just
37-
builds the Google Test library and a sample test. You can use it as a starting
38-
point for your own build script.
39-
40-
If the default settings are correct for your environment, the following commands
41-
should succeed:
42-
43-
cd ${GTEST_DIR}/make
44-
make
45-
./sample1_unittest
46-
47-
If you see errors, try to tweak the contents of `make/Makefile` to make them go
48-
away. There are instructions in `make/Makefile` on how to do it.
49-
50-
### Using CMake
9+
### Build with CMake
5110

5211
Google Test comes with a CMake build script (
5312
[CMakeLists.txt](https://github.com/google/googletest/blob/master/CMakeLists.txt))
@@ -115,60 +74,64 @@ pulled into the main build with `add_subdirectory()`. For example:
11574

11675
New file `CMakeLists.txt.in`:
11776

118-
cmake_minimum_required(VERSION 2.8.2)
77+
```cmake
78+
cmake_minimum_required(VERSION 2.8.2)
11979
120-
project(googletest-download NONE)
80+
project(googletest-download NONE)
12181
122-
include(ExternalProject)
123-
ExternalProject_Add(googletest
124-
GIT_REPOSITORY https://github.com/google/googletest.git
125-
GIT_TAG master
126-
SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-src"
127-
BINARY_DIR "${CMAKE_BINARY_DIR}/googletest-build"
128-
CONFIGURE_COMMAND ""
129-
BUILD_COMMAND ""
130-
INSTALL_COMMAND ""
131-
TEST_COMMAND ""
132-
)
82+
include(ExternalProject)
83+
ExternalProject_Add(googletest
84+
GIT_REPOSITORY https://github.com/google/googletest.git
85+
GIT_TAG master
86+
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-src"
87+
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-build"
88+
CONFIGURE_COMMAND ""
89+
BUILD_COMMAND ""
90+
INSTALL_COMMAND ""
91+
TEST_COMMAND ""
92+
)
93+
```
13394

13495
Existing build's `CMakeLists.txt`:
13596

136-
# Download and unpack googletest at configure time
137-
configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt)
138-
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
139-
RESULT_VARIABLE result
140-
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download )
141-
if(result)
142-
message(FATAL_ERROR "CMake step for googletest failed: ${result}")
143-
endif()
144-
execute_process(COMMAND ${CMAKE_COMMAND} --build .
145-
RESULT_VARIABLE result
146-
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download )
147-
if(result)
148-
message(FATAL_ERROR "Build step for googletest failed: ${result}")
149-
endif()
150-
151-
# Prevent overriding the parent project's compiler/linker
152-
# settings on Windows
153-
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
154-
155-
# Add googletest directly to our build. This defines
156-
# the gtest and gtest_main targets.
157-
add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src
158-
${CMAKE_BINARY_DIR}/googletest-build
159-
EXCLUDE_FROM_ALL)
160-
161-
# The gtest/gtest_main targets carry header search path
162-
# dependencies automatically when using CMake 2.8.11 or
163-
# later. Otherwise we have to add them here ourselves.
164-
if (CMAKE_VERSION VERSION_LESS 2.8.11)
165-
include_directories("${gtest_SOURCE_DIR}/include")
166-
endif()
167-
168-
# Now simply link against gtest or gtest_main as needed. Eg
169-
add_executable(example example.cpp)
170-
target_link_libraries(example gtest_main)
171-
add_test(NAME example_test COMMAND example)
97+
```cmake
98+
# Download and unpack googletest at configure time
99+
configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt)
100+
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
101+
RESULT_VARIABLE result
102+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
103+
if(result)
104+
message(FATAL_ERROR "CMake step for googletest failed: ${result}")
105+
endif()
106+
execute_process(COMMAND ${CMAKE_COMMAND} --build .
107+
RESULT_VARIABLE result
108+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
109+
if(result)
110+
message(FATAL_ERROR "Build step for googletest failed: ${result}")
111+
endif()
112+
113+
# Prevent overriding the parent project's compiler/linker
114+
# settings on Windows
115+
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
116+
117+
# Add googletest directly to our build. This defines
118+
# the gtest and gtest_main targets.
119+
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src
120+
${CMAKE_CURRENT_BINARY_DIR}/googletest-build
121+
EXCLUDE_FROM_ALL)
122+
123+
# The gtest/gtest_main targets carry header search path
124+
# dependencies automatically when using CMake 2.8.11 or
125+
# later. Otherwise we have to add them here ourselves.
126+
if (CMAKE_VERSION VERSION_LESS 2.8.11)
127+
include_directories("${gtest_SOURCE_DIR}/include")
128+
endif()
129+
130+
# Now simply link against gtest or gtest_main as needed. Eg
131+
add_executable(example example.cpp)
132+
target_link_libraries(example gtest_main)
133+
add_test(NAME example_test COMMAND example)
134+
```
172135

173136
Note that this approach requires CMake 2.8.2 or later due to its use of the
174137
`ExternalProject_Add()` command. The above technique is discussed in more detail
@@ -188,47 +151,14 @@ Google Test already has a CMake option for this: `gtest_force_shared_crt`
188151
Enabling this option will make gtest link the runtimes dynamically too, and
189152
match the project in which it is included.
190153

191-
### Legacy Build Scripts
192-
193-
Before settling on CMake, we have been providing hand-maintained build
194-
projects/scripts for Visual Studio, Xcode, and Autotools. While we continue to
195-
provide them for convenience, they are not actively maintained any more. We
196-
highly recommend that you follow the instructions in the above sections to
197-
integrate Google Test with your existing build system.
198-
199-
If you still need to use the legacy build scripts, here's how:
200-
201-
The msvc\ folder contains two solutions with Visual C++ projects. Open the
202-
`gtest.sln` or `gtest-md.sln` file using Visual Studio, and you are ready to
203-
build Google Test the same way you build any Visual Studio project. Files that
204-
have names ending with -md use DLL versions of Microsoft runtime libraries (the
205-
/MD or the /MDd compiler option). Files without that suffix use static versions
206-
of the runtime libraries (the /MT or the /MTd option). Please note that one must
207-
use the same option to compile both gtest and the test code. If you use Visual
208-
Studio 2005 or above, we recommend the -md version as /MD is the default for new
209-
projects in these versions of Visual Studio.
154+
#### C++ Standard Version
210155

211-
On Mac OS X, open the `gtest.xcodeproj` in the `xcode/` folder using Xcode.
212-
Build the "gtest" target. The universal binary framework will end up in your
213-
selected build directory (selected in the Xcode "Preferences..." -> "Building"
214-
pane and defaults to xcode/build). Alternatively, at the command line, enter:
215-
216-
xcodebuild
217-
218-
This will build the "Release" configuration of gtest.framework in your default
219-
build location. See the "xcodebuild" man page for more information about
220-
building different configurations and building in different locations.
221-
222-
If you wish to use the Google Test Xcode project with Xcode 4.x and above, you
223-
need to either:
224-
225-
* update the SDK configuration options in xcode/Config/General.xconfig.
226-
Comment options `SDKROOT`, `MACOS_DEPLOYMENT_TARGET`, and `GCC_VERSION`. If
227-
you choose this route you lose the ability to target earlier versions of
228-
MacOS X.
229-
* Install an SDK for an earlier version. This doesn't appear to be supported
230-
by Apple, but has been reported to work
231-
(http://stackoverflow.com/questions/5378518).
156+
An environment that supports C++11 is required in order to successfully build
157+
Google Test. One way to ensure this is to specify the standard in the top-level
158+
project, for example by using the `set(CMAKE_CXX_STANDARD 11)` command. If this
159+
is not feasible, for example in a C project using Google Test for validation,
160+
then it can be specified by adding it to the options for cmake via the
161+
`DCMAKE_CXX_FLAGS` option.
232162

233163
### Tweaking Google Test
234164

@@ -239,41 +169,14 @@ command line. Generally, these macros are named like `GTEST_XYZ` and you define
239169
them to either 1 or 0 to enable or disable a certain feature.
240170

241171
We list the most frequently used macros below. For a complete list, see file
242-
[include/gtest/internal/gtest-port.h](https://github.com/google/googletest/blob/master/include/gtest/internal/gtest-port.h).
243-
244-
### Choosing a TR1 Tuple Library
245-
246-
Some Google Test features require the C++ Technical Report 1 (TR1) tuple
247-
library, which is not yet available with all compilers. The good news is that
248-
Google Test implements a subset of TR1 tuple that's enough for its own need, and
249-
will automatically use this when the compiler doesn't provide TR1 tuple.
250-
251-
Usually you don't need to care about which tuple library Google Test uses.
252-
However, if your project already uses TR1 tuple, you need to tell Google Test to
253-
use the same TR1 tuple library the rest of your project uses, or the two tuple
254-
implementations will clash. To do that, add
255-
256-
-DGTEST_USE_OWN_TR1_TUPLE=0
257-
258-
to the compiler flags while compiling Google Test and your tests. If you want to
259-
force Google Test to use its own tuple library, just add
260-
261-
-DGTEST_USE_OWN_TR1_TUPLE=1
262-
263-
to the compiler flags instead.
264-
265-
If you don't want Google Test to use tuple at all, add
266-
267-
-DGTEST_HAS_TR1_TUPLE=0
268-
269-
and all features using tuple will be disabled.
172+
[include/gtest/internal/gtest-port.h](https://github.com/google/googletest/blob/master/googletest/include/gtest/internal/gtest-port.h).
270173

271174
### Multi-threaded Tests
272175

273176
Google Test is thread-safe where the pthread library is available. After
274-
`#include "gtest/gtest.h"`, you can check the `GTEST_IS_THREADSAFE` macro to see
275-
whether this is the case (yes if the macro is `#defined` to 1, no if it's
276-
undefined.).
177+
`#include "gtest/gtest.h"`, you can check the
178+
`GTEST_IS_THREADSAFE` macro to see whether this is the case (yes if the macro is
179+
`#defined` to 1, no if it's undefined.).
277180

278181
If Google Test doesn't correctly detect whether pthread is available in your
279182
environment, you can force it with

include/googletest/cmake/gtest.pc.in

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
2-
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
1+
prefix=${pcfiledir}/../..
2+
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
3+
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
34

45
Name: gtest
56
Description: GoogleTest (without main() function)

0 commit comments

Comments
 (0)