-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
338 lines (285 loc) · 7.58 KB
/
CMakeLists.txt
File metadata and controls
338 lines (285 loc) · 7.58 KB
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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# Copyright 2017 Google LLC
#
# 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.
include(CheckSymbolExists)
include(CheckIncludeFiles)
include(python_setup)
FirebaseSetupPythonInterpreter(
OUTVAR MY_PYTHON_EXECUTABLE
KEY FirestoreCore
)
## firestore_util
# The set of sources to use for firestore_util are complex.
file(
GLOB util_sources
src/util/*.cc
src/util/*.h
)
if(APPLE)
firebase_ios_glob(
util_sources APPEND src/util/*.mm
EXCLUDE src/util/*_win.cc
)
elseif(WIN32)
firebase_ios_glob(
util_sources EXCLUDE
src/util/*_apple.*
src/util/*_posix.*
)
else()
# Linux and other UNIX systems.
firebase_ios_glob(
util_sources EXCLUDE
src/util/*_apple.cc
src/util/*_win.cc
)
endif()
# Choose Executor implementation
# Comment out this check on macOS to build with ExecutorStd instead of
# ExecutorLibdispatch.
check_symbol_exists(dispatch_async_f dispatch/dispatch.h HAVE_LIBDISPATCH)
firebase_ios_glob(
util_sources EXCLUDE src/util/executor_*
)
if(HAVE_LIBDISPATCH)
firebase_ios_glob(
util_sources APPEND src/util/executor_libdispatch.*
)
else()
firebase_ios_glob(
util_sources APPEND src/util/executor_std.*
)
endif()
# Choose Logger implementation
firebase_ios_glob(
util_sources EXCLUDE src/util/log_*
)
# TODO(wilhuff): Can this be if(APPLE)?
if(IOS)
firebase_ios_glob(
util_sources APPEND src/util/log_apple.mm
)
else()
firebase_ios_glob(
util_sources APPEND src/util/log_stdio.cc
)
endif()
# Choose SecureRandom implementation
check_symbol_exists(arc4random stdlib.h HAVE_ARC4RANDOM)
if(TARGET OpenSSL::Crypto)
get_target_property(
CMAKE_REQUIRED_INCLUDES OpenSSL::Crypto INTERFACE_INCLUDE_DIRECTORIES
)
check_include_files(openssl/rand.h HAVE_OPENSSL_RAND_H)
endif()
firebase_ios_glob(
util_sources EXCLUDE src/util/secure_random_*.cc
)
if(HAVE_ARC4RANDOM)
firebase_ios_glob(
util_sources APPEND
src/util/secure_random_arc4random.cc
)
elseif(HAVE_OPENSSL_RAND_H)
firebase_ios_glob(
util_sources APPEND
src/util/secure_random_openssl.cc
)
else()
message(
FATAL_ERROR
"Don't know how to get high quality random numbers on this platform."
)
endif()
configure_file(
src/util/config_detected.h.in
src/util/config_detected.h # NOLINT(generated)
)
firebase_ios_add_library(firestore_util EXCLUDE_FROM_ALL ${util_sources})
target_compile_definitions(
firestore_util PUBLIC
FIRESTORE_HAVE_CONFIG_DETECTED_H
)
target_link_libraries(
firestore_util PUBLIC
absl::base
absl::memory
absl::meta
absl::optional
absl::strings
absl::time
protobuf-nanopb-static
firestore_protos_nanopb
grpc++
)
if(HAVE_OPENSSL_RAND_H)
target_link_libraries(
firestore_util PRIVATE
OpenSSL::Crypto
)
endif()
if(APPLE)
target_link_libraries(
firestore_util PUBLIC
"-framework CoreFoundation"
"-framework Foundation"
FirebaseCore
)
endif()
## firestore_nanopb
# Nanopb-related utilities that not specific to Firestore and are used from
# generated nanopb messages.
firebase_ios_glob(
nanopb_sources
src/nanopb/byte_string.*
src/nanopb/nanopb_util.*
src/nanopb/pretty_printing.*
)
firebase_ios_add_library(firestore_nanopb EXCLUDE_FROM_ALL ${nanopb_sources})
target_link_libraries(
firestore_nanopb PUBLIC
absl_strings
firestore_util
protobuf-nanopb-static
)
## firestore_core
firebase_ios_glob(
core_sources
include/firebase/firestore/*.h
src/*.cc
src/*.h
src/api/*.cc
src/api/*.h
src/bundle/*.cc
src/bundle/*.h
src/core/*.cc
src/core/*.h
src/credentials/*.cc
src/credentials/*.h
src/immutable/*.cc
src/immutable/*.h
src/index/*.cc
src/index/*.h
src/local/*.cc
src/local/*.h
src/model/*.cc
src/model/*.h
src/model/mutation/*.cc
src/model/mutation/*.h
src/nanopb/*.cc
src/nanopb/*.h
src/objc/*.h
src/remote/*.cc
src/remote/*.h
EXCLUDE ${nanopb_sources}
)
if(APPLE)
firebase_ios_glob(
core_sources APPEND
src/credentials/firebase_app_check_credentials_provider_apple.*
src/credentials/firebase_auth_credentials_provider_apple.*
src/remote/connectivity_monitor_apple.mm
src/remote/firebase_metadata_provider_apple.mm
)
endif()
firebase_ios_add_library(firestore_core ${core_sources})
podspec_version(version ${PROJECT_SOURCE_DIR}/FirebaseFirestore.podspec)
target_compile_definitions(
firestore_core PRIVATE
FIRFirestore_VERSION=${version}
)
target_include_directories(
firestore_core PUBLIC
${PROJECT_SOURCE_DIR}/Firestore/core/include
)
# Add the gRPC include directories as SYSTEM directories to silence warnings
target_include_directories(
firestore_core
SYSTEM # The SYSTEM keyword applies to all directories in this block
PUBLIC
# This generator expression automatically gets the correct include path(s) from the grpc++ target
$<TARGET_PROPERTY:grpc++,INTERFACE_INCLUDE_DIRECTORIES>
)
target_link_libraries(
firestore_core PUBLIC
LevelDB::LevelDB
absl::base
absl::memory
absl::meta
absl::optional
absl::strings
firestore_nanopb
firestore_protos_nanopb
firestore_util
grpc++
protobuf-nanopb-static
)
if(APPLE)
target_link_libraries(
firestore_core PUBLIC
"-framework Foundation"
"-framework SystemConfiguration"
FirebaseAppCheckInterop
FirebaseAuthInterop
FirebaseCore
)
endif()
## gRPC Certificates
# Source files should be generated in place so that the Xcode build can pick
# them up.
set(OUTPUT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/remote)
set(
GRPC_ROOT_CERTIFICATE_SOURCES
${OUTPUT_DIR}/grpc_root_certificates_generated.h # NOLINT(generated)
${OUTPUT_DIR}/grpc_root_certificates_generated.cc # NOLINT(generated)
)
# `roots.pem` is a file containing root certificates that is distributed
# alongside gRPC and is necessary to establish SSL connections. Embed this file
# into the binary by converting it to a char array.
add_custom_command(
COMMENT "Generating root certificates for embedding"
OUTPUT
${GRPC_ROOT_CERTIFICATE_SOURCES}
COMMAND
${MY_PYTHON_EXECUTABLE} ${FIREBASE_SOURCE_DIR}/scripts/binary_to_array.py
--output_header=${OUTPUT_DIR}/grpc_root_certificates_generated.h
--output_source=${OUTPUT_DIR}/grpc_root_certificates_generated.cc
--cpp_namespace=firebase::firestore::remote
--array=grpc_root_certificates_generated_data
--array_size=grpc_root_certificates_generated_size
${FIREBASE_EXTERNAL_SOURCE_DIR}/grpc/etc/roots.pem
VERBATIM
DEPENDS
grpc
${FIREBASE_SOURCE_DIR}/scripts/binary_to_array.py
${FIREBASE_EXTERNAL_SOURCE_DIR}/grpc/etc/roots.pem
)
# gRPC certificates have to be regenerated manually on each new gRPC release
# (which typically has updated certificates).
add_custom_target(
firestore_gen_grpc_certs
DEPENDS ${GRPC_ROOT_CERTIFICATE_SOURCES}
)
add_subdirectory(test/unit/testutil)
add_subdirectory(test/unit)
add_subdirectory(test/unit/api)
add_subdirectory(test/unit/bundle)
add_subdirectory(test/unit/credentials)
add_subdirectory(test/unit/core)
add_subdirectory(test/unit/immutable)
add_subdirectory(test/unit/local)
add_subdirectory(test/unit/model)
add_subdirectory(test/unit/objc)
add_subdirectory(test/unit/nanopb)
add_subdirectory(test/unit/remote)
add_subdirectory(test/unit/util)