Skip to content

Commit 526bb04

Browse files
committed
Update abseil-cpp to a new upstream
Update to 7990fd459e9339467814ddb95000c87cb1e4d945 master@{2018-11-06}
1 parent 7be6e40 commit 526bb04

File tree

991 files changed

+101698
-742
lines changed

Some content is hidden

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

991 files changed

+101698
-742
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Please submit a new Abseil Issue using the template below:
2+
3+
## [Short title of proposed API change(s)]
4+
5+
--------------------------------------------------------------------------------
6+
--------------------------------------------------------------------------------
7+
8+
## Background
9+
10+
[Provide the background information that is required in order to evaluate the
11+
proposed API changes. No controversial claims should be made here. If there are
12+
design constraints that need to be considered, they should be presented here
13+
**along with justification for those constraints**. Linking to other docs is
14+
good, but please keep the **pertinent information as self contained** as
15+
possible in this section.]
16+
17+
## Proposed API Change (s)
18+
19+
[Please clearly describe the API change(s) being proposed. If multiple changes,
20+
please keep them clearly distinguished. When possible, **use example code
21+
snippets to illustrate before-after API usages**. List pros-n-cons. Highlight
22+
the main questions that you want to be answered. Given the Abseil project compatibility requirements, describe why the API change is safe.]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# This is the list of Abseil authors for copyright purposes.
2+
#
3+
# This does not necessarily list everyone who has contributed code, since in
4+
# some cases, their employer may be the copyright holder. To see the full list
5+
# of contributors, see the revision history in source control.
6+
Google Inc.

Firestore/third_party/abseil-cpp/CMake/AbseilHelpers.cmake

Lines changed: 122 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616

1717
include(CMakeParseArguments)
1818

19+
# The IDE folder for Abseil that will be used if Abseil is included in a CMake
20+
# project that sets
21+
# set_property(GLOBAL PROPERTY USE_FOLDERS ON)
22+
# For example, Visual Studio supports folders.
23+
set(ABSL_IDE_FOLDER Abseil)
1924

2025
#
2126
# create a library in the absl namespace
@@ -34,7 +39,7 @@ function(absl_library)
3439
cmake_parse_arguments(ABSL_LIB
3540
"DISABLE_INSTALL" # keep that in case we want to support installation one day
3641
"TARGET;EXPORT_NAME"
37-
"SOURCES;PUBLIC_LIBRARIES;PRIVATE_COMPILE_FLAGS;PUBLIC_INCLUDE_DIRS;PRIVATE_INCLUDE_DIRS"
42+
"SOURCES;PUBLIC_LIBRARIES;PRIVATE_COMPILE_FLAGS"
3843
${ARGN}
3944
)
4045

@@ -43,19 +48,123 @@ function(absl_library)
4348

4449
add_library(${_NAME} STATIC ${ABSL_LIB_SOURCES})
4550

46-
target_compile_options(${_NAME} PRIVATE ${ABSL_COMPILE_CXXFLAGS} ${ABSL_LIB_PRIVATE_COMPILE_FLAGS})
51+
target_compile_options(${_NAME} PRIVATE ${ABSL_LIB_PRIVATE_COMPILE_FLAGS})
4752
target_link_libraries(${_NAME} PUBLIC ${ABSL_LIB_PUBLIC_LIBRARIES})
4853
target_include_directories(${_NAME}
4954
PUBLIC ${ABSL_COMMON_INCLUDE_DIRS} ${ABSL_LIB_PUBLIC_INCLUDE_DIRS}
5055
PRIVATE ${ABSL_LIB_PRIVATE_INCLUDE_DIRS}
5156
)
57+
# Add all Abseil targets to a a folder in the IDE for organization.
58+
set_property(TARGET ${_NAME} PROPERTY FOLDER ${ABSL_IDE_FOLDER})
5259

5360
if(ABSL_LIB_EXPORT_NAME)
5461
add_library(absl::${ABSL_LIB_EXPORT_NAME} ALIAS ${_NAME})
5562
endif()
5663
endfunction()
5764

65+
#
66+
# CMake function to imitate Bazel's cc_library rule.
67+
#
68+
# Parameters:
69+
# NAME: name of target (see Note)
70+
# HDRS: List of public header files for the library
71+
# SRCS: List of source files for the library
72+
# DEPS: List of other libraries to be linked in to the binary targets
73+
# COPTS: List of private compile options
74+
# DEFINES: List of public defines
75+
# LINKOPTS: List of link options
76+
# PUBLIC: Add this so that this library will be exported under absl:: (see Note).
77+
# TESTONLY: When added, this target will only be built if user passes -DABSL_RUN_TESTS=ON to CMake.
78+
#
79+
# Note:
80+
#
81+
# By default, absl_cc_library will always create a library named absl_internal_${NAME},
82+
# which means other targets can only depend this library as absl_internal_${NAME}, not ${NAME}.
83+
# This is to reduce namespace pollution.
84+
#
85+
# absl_cc_library(
86+
# NAME
87+
# awesome_lib
88+
# HDRS
89+
# "a.h"
90+
# SRCS
91+
# "a.cc"
92+
# )
93+
# absl_cc_library(
94+
# NAME
95+
# fantastic_lib
96+
# SRCS
97+
# "b.cc"
98+
# DEPS
99+
# absl_internal_awesome_lib # not "awesome_lib"!
100+
# )
101+
#
102+
# If PUBLIC is set, absl_cc_library will instead create a target named
103+
# absl_${NAME} and an alias absl::${NAME}.
104+
#
105+
# absl_cc_library(
106+
# NAME
107+
# main_lib
108+
# ...
109+
# PUBLIC
110+
# )
111+
#
112+
# User can then use the library as absl::main_lib (although absl_main_lib is defined too).
113+
#
114+
# TODO: Implement "ALWAYSLINK"
115+
116+
function(absl_cc_library)
117+
cmake_parse_arguments(ABSL_CC_LIB
118+
"DISABLE_INSTALL;PUBLIC;TESTONLY"
119+
"NAME"
120+
"HDRS;SRCS;COPTS;DEFINES;LINKOPTS;DEPS"
121+
${ARGN}
122+
)
58123

124+
if (NOT ABSL_CC_LIB_TESTONLY OR ABSL_RUN_TESTS)
125+
if (ABSL_CC_LIB_PUBLIC)
126+
set(_NAME "absl_${ABSL_CC_LIB_NAME}")
127+
else()
128+
set(_NAME "absl_internal_${ABSL_CC_LIB_NAME}")
129+
endif()
130+
131+
# Check if this is a header-only library
132+
if ("${ABSL_CC_LIB_SRCS}" STREQUAL "")
133+
set(ABSL_CC_LIB_IS_INTERFACE 1)
134+
else()
135+
set(ABSL_CC_LIB_IS_INTERFACE 0)
136+
endif()
137+
138+
if(NOT ABSL_CC_LIB_IS_INTERFACE)
139+
add_library(${_NAME} STATIC "")
140+
target_sources(${_NAME} PRIVATE ${ABSL_CC_LIB_SRCS} ${ABSL_CC_LIB_HDRS})
141+
target_include_directories(${_NAME}
142+
PUBLIC ${ABSL_COMMON_INCLUDE_DIRS})
143+
target_compile_options(${_NAME}
144+
PRIVATE ${ABSL_CC_LIB_COPTS})
145+
target_link_libraries(${_NAME}
146+
PUBLIC ${ABSL_CC_LIB_DEPS}
147+
PRIVATE ${ABSL_CC_LIB_LINKOPTS}
148+
)
149+
target_compile_definitions(${_NAME} PUBLIC ${ABSL_CC_LIB_DEFINES})
150+
151+
# Add all Abseil targets to a a folder in the IDE for organization.
152+
set_property(TARGET ${_NAME} PROPERTY FOLDER ${ABSL_IDE_FOLDER})
153+
else()
154+
# Generating header-only library
155+
add_library(${_NAME} INTERFACE)
156+
target_include_directories(${_NAME} INTERFACE ${ABSL_COMMON_INCLUDE_DIRS})
157+
target_link_libraries(${_NAME}
158+
INTERFACE ${ABSL_CC_LIB_DEPS} ${ABSL_CC_LIB_LINKOPTS}
159+
)
160+
target_compile_definitions(${_NAME} INTERFACE ${ABSL_CC_LIB_DEFINES})
161+
endif()
162+
163+
if(ABSL_CC_LIB_PUBLIC)
164+
add_library(absl::${ABSL_CC_LIB_NAME} ALIAS ${_NAME})
165+
endif()
166+
endif()
167+
endfunction()
59168

60169
#
61170
# header only virtual target creation
@@ -93,6 +202,9 @@ function(absl_header_library)
93202
PRIVATE ${ABSL_HO_LIB_PRIVATE_INCLUDE_DIRS}
94203
)
95204

205+
# Add all Abseil targets to a a folder in the IDE for organization.
206+
set_property(TARGET ${_NAME} PROPERTY FOLDER ${ABSL_IDE_FOLDER})
207+
96208
if(ABSL_HO_LIB_EXPORT_NAME)
97209
add_library(absl::${ABSL_HO_LIB_EXPORT_NAME} ALIAS ${_NAME})
98210
endif()
@@ -113,7 +225,7 @@ endfunction()
113225
#
114226
# all tests will be register for execution with add_test()
115227
#
116-
# test compilation and execution is disable when BUILD_TESTING=OFF
228+
# test compilation and execution is disable when ABSL_RUN_TESTS=OFF
117229
#
118230
function(absl_test)
119231

@@ -125,22 +237,25 @@ function(absl_test)
125237
)
126238

127239

128-
if(BUILD_TESTING)
240+
if(ABSL_RUN_TESTS)
129241

130242
set(_NAME ${ABSL_TEST_TARGET})
131243
string(TOUPPER ${_NAME} _UPPER_NAME)
132244

133245
add_executable(${_NAME}_bin ${ABSL_TEST_SOURCES})
134246

135-
target_compile_options(${_NAME}_bin PRIVATE ${ABSL_COMPILE_CXXFLAGS} ${ABSL_TEST_PRIVATE_COMPILE_FLAGS})
247+
target_compile_options(${_NAME}_bin PRIVATE ${ABSL_TEST_PRIVATE_COMPILE_FLAGS})
136248
target_link_libraries(${_NAME}_bin PUBLIC ${ABSL_TEST_PUBLIC_LIBRARIES} ${ABSL_TEST_COMMON_LIBRARIES})
137249
target_include_directories(${_NAME}_bin
138250
PUBLIC ${ABSL_COMMON_INCLUDE_DIRS} ${ABSL_TEST_PUBLIC_INCLUDE_DIRS}
139251
PRIVATE ${GMOCK_INCLUDE_DIRS} ${GTEST_INCLUDE_DIRS}
140252
)
141253

142-
add_test(${_NAME}_test ${_NAME}_bin)
143-
endif(BUILD_TESTING)
254+
# Add all Abseil targets to a a folder in the IDE for organization.
255+
set_property(TARGET ${_NAME}_bin PROPERTY FOLDER ${ABSL_IDE_FOLDER})
256+
257+
add_test(${_NAME} ${_NAME}_bin)
258+
endif(ABSL_RUN_TESTS)
144259

145260
endfunction()
146261

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
cmake_minimum_required(VERSION 2.8.2)
2+
3+
project(googletest-download NONE)
4+
5+
include(ExternalProject)
6+
ExternalProject_Add(googletest
7+
GIT_REPOSITORY https://github.com/google/googletest.git
8+
GIT_TAG master
9+
SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-src"
10+
BINARY_DIR "${CMAKE_BINARY_DIR}/googletest-build"
11+
CONFIGURE_COMMAND ""
12+
BUILD_COMMAND ""
13+
INSTALL_COMMAND ""
14+
TEST_COMMAND ""
15+
)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Downloads and unpacks googletest at configure time. Based on the instructions
2+
# at https://github.com/google/googletest/tree/master/googletest#incorporating-into-an-existing-cmake-project
3+
4+
# Download the latest googletest from Github master
5+
configure_file(
6+
${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt.in
7+
googletest-download/CMakeLists.txt
8+
)
9+
10+
# Configure and build the downloaded googletest source
11+
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
12+
RESULT_VARIABLE result
13+
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download )
14+
if(result)
15+
message(FATAL_ERROR "CMake step for googletest failed: ${result}")
16+
endif()
17+
18+
execute_process(COMMAND ${CMAKE_COMMAND} --build .
19+
RESULT_VARIABLE result
20+
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download)
21+
if(result)
22+
message(FATAL_ERROR "Build step for googletest failed: ${result}")
23+
endif()
24+
25+
# Prevent overriding the parent project's compiler/linker settings on Windows
26+
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
27+
28+
# Add googletest directly to our build. This defines the gtest and gtest_main
29+
# targets.
30+
add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src
31+
${CMAKE_BINARY_DIR}/googletest-build
32+
EXCLUDE_FROM_ALL)
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Abseil CMake Build Instructions
2+
3+
Abseil comes with a CMake build script ([CMakeLists.txt](../CMakeLists.txt))
4+
that can be used on a wide range of platforms ("C" stands for cross-platform.).
5+
If you don't have CMake installed already, you can download it for free from
6+
<http://www.cmake.org/>.
7+
8+
CMake works by generating native makefiles or build projects that can
9+
be used in the compiler environment of your choice.
10+
11+
For API/ABI compatibility reasons, we strongly recommend building Abseil in a
12+
subdirectory of your project or as an embedded dependency.
13+
14+
## Incorporating Abseil Into a CMake Project
15+
16+
The recommendations below are similar to those for using CMake within the
17+
googletest framework
18+
(<https://github.com/google/googletest/blob/master/googletest/README.md#incorporating-into-an-existing-cmake-project>)
19+
20+
### Step-by-Step Instructions
21+
22+
1. If you want to build the Abseil tests, integrate the Abseil dependency
23+
[Google Test](https://github.com/google/googletest) into your CMake project. To disable Abseil tests, you have to pass
24+
`-DBUILD_TESTING=OFF` when configuring your project with CMake.
25+
26+
2. Download Abseil and copy it into a subdirectory in your CMake project or add
27+
Abseil as a [git submodule](https://git-scm.com/docs/git-submodule) in your
28+
CMake project.
29+
30+
3. You can then use the CMake command
31+
[`add_subdirectory()`](https://cmake.org/cmake/help/latest/command/add_subdirectory.html)
32+
to include Abseil directly in your CMake project.
33+
34+
4. Add the **absl::** target you wish to use to the
35+
[`target_link_libraries()`](https://cmake.org/cmake/help/latest/command/target_link_libraries.html)
36+
section of your executable or of your library.<br>
37+
Here is a short CMakeLists.txt example of a project file using Abseil.
38+
39+
```cmake
40+
cmake_minimum_required(VERSION 2.8.12)
41+
project(my_project)
42+
43+
set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++ ${CMAKE_CXX_FLAGS}")
44+
45+
if(MSVC)
46+
# /wd4005 macro-redefinition
47+
# /wd4068 unknown pragma
48+
# /wd4244 conversion from 'type1' to 'type2'
49+
# /wd4267 conversion from 'size_t' to 'type2'
50+
# /wd4800 force value to bool 'true' or 'false' (performance warning)
51+
add_compile_options(/wd4005 /wd4068 /wd4244 /wd4267 /wd4800)
52+
add_definitions(/DNOMINMAX /DWIN32_LEAN_AND_MEAN=1 /D_CRT_SECURE_NO_WARNINGS)
53+
endif()
54+
55+
add_subdirectory(abseil-cpp)
56+
57+
add_executable(my_exe source.cpp)
58+
target_link_libraries(my_exe absl::base absl::synchronization absl::strings)
59+
```
60+
61+
### Running Abseil Tests with CMake
62+
63+
Use the `-DABSL_RUN_TESTS=ON` flag to run Abseil tests. Note that if the `-DBUILD_TESTING=OFF` flag is passed then Abseil tests will not be run.
64+
65+
You will need to provide Abseil with a Googletest dependency. There are two
66+
options for how to do this:
67+
68+
* Use `-DABSL_USE_GOOGLETEST_HEAD`. This will automatically download the latest
69+
Googletest source into the build directory at configure time. Googletest will
70+
then be compiled directly alongside Abseil's tests.
71+
* Manually integrate Googletest with your build. See
72+
https://github.com/google/googletest/blob/master/googletest/README.md#using-cmake
73+
for more information on using Googletest in a CMake project.
74+
75+
For example, to run just the Abseil tests, you could use this script:
76+
77+
```
78+
cd path/to/abseil-cpp
79+
mkdir build
80+
cd build
81+
cmake -DABSL_USE_GOOGLETEST_HEAD=ON -DABSL_RUN_TESTS=ON ..
82+
make -j
83+
ctest
84+
```
85+
86+
Currently, we only run our tests with CMake in a Linux environment, but we are
87+
working on the rest of our supported platforms. See
88+
https://github.com/abseil/abseil-cpp/projects/1 and
89+
https://github.com/abseil/abseil-cpp/issues/109 for more information.
90+
91+
### Available Abseil CMake Public Targets
92+
93+
Here's a non-exhaustive list of Abseil CMake public targets:
94+
95+
```cmake
96+
absl::base
97+
absl::algorithm
98+
absl::container
99+
absl::debugging
100+
absl::memory
101+
absl::meta
102+
absl::numeric
103+
absl::strings
104+
absl::synchronization
105+
absl::time
106+
absl::utility
107+
```

0 commit comments

Comments
 (0)