forked from firebase/firebase-ios-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
252 lines (203 loc) · 6.52 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# Copyright 2017 Google
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Superbuild for Firebase
cmake_minimum_required(VERSION 3.5.1)
# Disallow mixing keyword and non-keyword forms of target_link_libraries
if(POLICY CMP0023)
cmake_policy(SET CMP0023 NEW)
endif()
# Report AppleClang separately from Clang. Their version numbers are different.
# https://cmake.org/cmake/help/v3.0/policy/CMP0025.html
if(POLICY CMP0025)
cmake_policy(SET CMP0025 NEW)
endif()
# Enable rpath by default
if(POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif()
# Generate Ninja phony rules for unknown dependencies in the build tree and
# don't complain about doing so. Our dependencies aren't good about declaring
# BYPRODUCTS and we mix them all into a single uber build so we can't enable
# this policy until all dependencies are capable of doing so.
if(POLICY CMP0058)
cmake_policy(SET CMP0058 OLD)
endif()
# Enable the ccache compilation cache, if available.
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
endif()
# Defer enabling any languages.
project(firebase NONE)
if(WIN32)
# On Windows, prefer cl over gcc if both are available. By default most of
# the CMake generators prefer gcc, even on Windows.
set(CMAKE_GENERATOR_CC cl)
endif()
enable_language(C)
enable_language(CXX)
list(INSERT CMAKE_MODULE_PATH 0 ${PROJECT_SOURCE_DIR}/cmake)
include(compiler_id)
include(archive_options)
include(sanitizer_options)
include(fuzzing_options)
# rules depend on properties and options set above
include(external_rules)
include(podspec_rules)
include(cc_rules)
# If no build type is specified, make it a debug build
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()
set(FIREBASE_SOURCE_DIR ${PROJECT_SOURCE_DIR})
set(FIREBASE_BINARY_DIR ${PROJECT_BINARY_DIR})
set(FIREBASE_INSTALL_DIR ${PROJECT_BINARY_DIR}/opt)
set(
FIREBASE_DOWNLOAD_DIR
${PROJECT_BINARY_DIR}/downloads
CACHE PATH "Where to store downloaded files"
)
set(
FIREBASE_EXTERNAL_SOURCE_DIR
${FIREBASE_BINARY_DIR}/external/src
CACHE PATH "Root directory of source code of the external dependencies"
)
download_external_sources()
# Googletest
set(gtest_force_shared_crt ON CACHE BOOL "Use shared run-time")
add_external_subdirectory(googletest)
add_alias(GTest::GTest gtest)
add_alias(GTest::Main gtest_main)
add_alias(GMock::GMock gmock)
# Benchmark
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "Firestore disabled")
set(BENCHMARK_ENABLE_EXCEPTIONS OFF CACHE BOOL "Firestore disabled")
set(BENCHMARK_ENABLE_INSTALL OFF CACHE BOOL "Firestore disabled")
set(BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE BOOL "Firestore disabled")
add_external_subdirectory(benchmark)
# Abseil-cpp
# Force disable Abseil's tests, which don't compile under VS2017.
set(old_build_testing ${BUILD_TESTING})
set(ABSL_RUN_TESTS OFF CACHE BOOL "Disable Abseil tests" FORCE)
add_external_subdirectory(abseil-cpp)
if(CXX_CLANG)
target_compile_options(
absl_time_zone
PRIVATE
-Wno-unused-template
-Wno-shadow
-Wno-tautological-type-limit-compare
)
endif()
if(MSVC)
# Disable warnings about unsafe use of std::copy
target_compile_definitions(
absl_strings
PUBLIC
_SCL_SECURE_NO_WARNINGS=1
)
endif()
# gRPC
find_package(OpenSSL QUIET)
if(OPENSSL_FOUND)
set(gRPC_SSL_PROVIDER package CACHE STRING "Use external OpenSSL")
endif()
find_package(ZLIB QUIET)
if(ZLIB_FOUND)
set(gRPC_ZLIB_PROVIDER package CACHE STRING "Use external ZLIB")
endif()
set(gRPC_BUILD_TESTS OFF CACHE BOOL "Disable gRPC tests")
add_external_subdirectory(grpc)
# Fix up targets included by gRPC's build
if(OPENSSL_FOUND)
# gRPC's CMakeLists.txt does not account for finding OpenSSL in a directory
# that's not in the default search path.
target_include_directories(grpc PRIVATE ${OPENSSL_INCLUDE_DIR})
if(CXX_CLANG OR CXX_GNU)
if((OPENSSL_VERSION VERSION_EQUAL "1.1.0") OR
(OPENSSL_VERSION VERSION_GREATER "1.1.0"))
# gRPC uses some features deprecated in OpenSSL 1.1.0
target_compile_options(
grpc
PRIVATE -Wno-deprecated-declarations
)
endif()
endif()
else()
# Not using outboard OpenSSL so set up BoringSSL to look like it.
add_alias(OpenSSL::Crypto crypto)
target_include_directories(
crypto
INTERFACE
$<BUILD_INTERFACE:${FIREBASE_EXTERNAL_SOURCE_DIR}/grpc/third_party/boringssl/include>
)
add_alias(OpenSSL::SSL ssl)
target_include_directories(
ssl
INTERFACE
$<BUILD_INTERFACE:${FIREBASE_EXTERNAL_SOURCE_DIR}/grpc/third_party/boringssl/include>
)
endif()
add_alias(protobuf::libprotobuf libprotobuf)
if(CXX_CLANG OR CXX_GNU)
target_compile_options(
libprotobuf
PUBLIC -Wno-unused-parameter
)
endif()
if(CXX_CLANG)
target_compile_options(
libprotobuf
PRIVATE
-Wno-inconsistent-missing-override
-Wno-invalid-offsetof
)
endif()
if(NOT ZLIB_FOUND)
target_include_directories(
zlibstatic
INTERFACE $<BUILD_INTERFACE:${FIREBASE_EXTERNAL_SOURCE_DIR}/grpc/third_party/zlib>
)
endif()
# LevelDB
set(LEVELDB_BUILD_TESTS OFF CACHE BOOL "Firestore disabled")
set(LEVELDB_BUILD_BENCHMARKS OFF CACHE BOOL "Firestore disabled")
set(LEVELDB_INSTALL OFF CACHE BOOL "Firestore disabled")
add_external_subdirectory(leveldb)
add_alias(LevelDB::LevelDB leveldb)
# nanopb
set(nanopb_BUILD_GENERATOR ON CACHE BOOL "Enable the nanopb generator")
set(nanopb_MSVC_STATIC_RUNTIME OFF CACHE BOOL "Link static runtime libraries")
add_external_subdirectory(nanopb)
target_compile_definitions(
protobuf-nanopb-static
PUBLIC -DPB_FIELD_32BIT -DPB_ENABLE_MALLOC
)
# Enable #include <nanopb/pb.h>
target_include_directories(
protobuf-nanopb-static
INTERFACE
$<BUILD_INTERFACE:${FIREBASE_EXTERNAL_SOURCE_DIR}>
$<BUILD_INTERFACE:${FIREBASE_EXTERNAL_SOURCE_DIR}/nanopb>
)
# XCTest
find_package(XCTest)
enable_testing()
include(compiler_setup)
add_subdirectory(Firebase/Core)
add_subdirectory(Firestore)
add_subdirectory(GoogleUtilities)
add_subdirectory(Interop/Auth)
add_subdirectory(Interop/CoreDiagnostics)