-
Notifications
You must be signed in to change notification settings - Fork 117
/
Copy pathCMakeLists.txt
451 lines (419 loc) · 14.9 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
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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
# Copyright 2020 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.
if(APPLE AND NOT ANDROID)
set(settings_apple_SRCS
src/common/settings_apple.mm)
else()
set(settings_apple_SRCS)
endif()
set(common_SRCS
src/common/aggregate_query.cc
src/common/aggregate_query_snapshot.cc
src/common/cleanup.h
src/common/collection_reference.cc
src/common/compiler_info.cc
src/common/compiler_info.h
src/common/document_change.cc
src/common/document_reference.cc
src/common/document_snapshot.cc
src/common/exception_common.cc
src/common/exception_common.h
src/common/filter.cc
src/common/field_path.cc
src/common/field_value.cc
src/common/firestore.cc
src/common/firestore_exceptions_common.h
src/common/futures.cc
src/common/futures.h
src/common/hard_assert_common.cc
src/common/hard_assert_common.h
src/common/listener_registration.cc
src/common/load_bundle_task_progress.cc
src/common/macros.h
src/common/query.cc
src/common/query_snapshot.cc
src/common/set_options.cc
src/common/settings.cc
src/common/snapshot_metadata.cc
src/common/to_string.cc
src/common/to_string.h
src/common/type_mapping.h
src/common/transaction.cc
src/common/transaction_options.cc
src/common/util.cc
src/common/util.h
src/common/write_batch.cc
${settings_apple_SRCS})
# Define the resource build needed for Android
firebase_cpp_gradle(":firestore:firestore_resources:generateDexJarRelease"
"${CMAKE_CURRENT_LIST_DIR}/firestore_resources/build/firestore_resources_lib.jar")
binary_to_array("firestore_resources"
"${CMAKE_CURRENT_LIST_DIR}/firestore_resources/build/firestore_resources_lib.jar"
"firebase_firestore"
"${FIREBASE_GEN_FILE_DIR}/firestore")
set(android_SRCS
${firestore_resources_source}
src/android/aggregate_query_android.cc
src/android/aggregate_query_android.h
src/android/aggregate_query_snapshot_android.cc
src/android/aggregate_query_snapshot_android.h
src/android/aggregate_source_android.cc
src/android/aggregate_source_android.h
src/android/blob_android.cc
src/android/blob_android.h
src/android/collection_reference_android.cc
src/android/collection_reference_android.h
src/android/direction_android.cc
src/android/direction_android.h
src/android/document_change_android.cc
src/android/document_change_android.h
src/android/document_change_type_android.cc
src/android/document_change_type_android.h
src/android/document_reference_android.cc
src/android/document_reference_android.h
src/android/document_snapshot_android.cc
src/android/document_snapshot_android.h
src/android/event_listener_android.cc
src/android/event_listener_android.h
src/android/exception_android.cc
src/android/exception_android.h
src/android/field_path_android.cc
src/android/field_path_android.h
src/android/field_path_portable.cc
src/android/field_path_portable.h
src/android/field_value_android.cc
src/android/field_value_android.h
src/android/filter_android.cc
src/android/filter_android.h
src/android/firestore_android.cc
src/android/firestore_android.h
src/android/firestore_exceptions_android.h
src/android/geo_point_android.cc
src/android/geo_point_android.h
src/android/geo_point_portable.cc
src/android/jni_runnable_android.cc
src/android/jni_runnable_android.h
src/android/lambda_event_listener.h
src/android/lambda_transaction_function.h
src/android/listener_registration_android.cc
src/android/listener_registration_android.h
src/android/load_bundle_task_android.cc
src/android/load_bundle_task_android.h
src/android/load_bundle_task_progress_android.cc
src/android/load_bundle_task_progress_android.h
src/android/metadata_changes_android.cc
src/android/metadata_changes_android.h
src/android/promise_android.h
src/android/promise_factory_android.h
src/android/query_android.cc
src/android/query_android.h
src/android/query_snapshot_android.cc
src/android/query_snapshot_android.h
src/android/server_timestamp_behavior_android.cc
src/android/server_timestamp_behavior_android.h
src/android/set_options_android.cc
src/android/set_options_android.h
src/android/settings_android.cc
src/android/settings_android.h
src/android/snapshot_metadata_android.cc
src/android/snapshot_metadata_android.h
src/android/source_android.cc
src/android/source_android.h
src/android/timestamp_android.cc
src/android/timestamp_android.h
src/android/timestamp_portable.cc
src/android/transaction_android.cc
src/android/transaction_android.h
src/android/transaction_options_android.cc
src/android/transaction_options_android.h
src/android/transaction_options_builder_android.cc
src/android/transaction_options_builder_android.h
src/android/util_android.cc
src/android/util_android.h
src/android/wrapper.cc
src/android/wrapper.h
src/android/write_batch_android.cc
src/android/write_batch_android.h
src/jni/array.h
src/jni/array_list.cc
src/jni/array_list.h
src/jni/arena_ref.cc
src/jni/arena_ref.h
src/jni/boolean.cc
src/jni/boolean.h
src/jni/call_traits.h
src/jni/class.cc
src/jni/class.h
src/jni/collection.cc
src/jni/collection.h
src/jni/compare.h
src/jni/declaration.h
src/jni/double.cc
src/jni/double.h
src/jni/env.cc
src/jni/env.h
src/jni/hash_map.cc
src/jni/hash_map.h
src/jni/integer.cc
src/jni/integer.h
src/jni/iterator.cc
src/jni/iterator.h
src/jni/jni.cc
src/jni/jni.h
src/jni/jni_fwd.h
src/jni/list.cc
src/jni/list.h
src/jni/loader.cc
src/jni/loader.h
src/jni/long.cc
src/jni/long.h
src/jni/map.cc
src/jni/map.h
src/jni/object.cc
src/jni/object.h
src/jni/ownership.h
src/jni/set.h
src/jni/string.cc
src/jni/string.h
src/jni/task.cc
src/jni/task.h
src/jni/throwable.cc
src/jni/throwable.h
src/jni/traits.h)
# Sources that apply to all non-Android platforms.
set(main_SRCS
src/main/aggregate_query_main.cc
src/main/aggregate_query_main.h
src/main/aggregate_query_snapshot_main.cc
src/main/aggregate_query_snapshot_main.h
src/main/collection_reference_main.cc
src/main/collection_reference_main.h
src/main/composite_filter_main.cc
src/main/composite_filter_main.h
src/main/converter_main.h
src/main/document_change_main.cc
src/main/document_change_main.h
src/main/document_reference_main.cc
src/main/document_reference_main.h
src/main/document_snapshot_main.cc
src/main/document_snapshot_main.h
src/main/filter_main.cc
src/main/filter_main.h
src/main/field_value_main.cc
src/main/field_value_main.h
src/main/firestore_main.cc
src/main/firestore_main.h
src/main/listener_main.h
src/main/listener_registration_main.cc
src/main/listener_registration_main.h
src/main/promise_factory_main.h
src/main/promise_main.h
src/main/query_main.cc
src/main/query_main.h
src/main/query_snapshot_main.cc
src/main/query_snapshot_main.h
src/main/set_options_main.h
src/main/source_main.h
src/main/transaction_main.cc
src/main/transaction_main.h
src/main/user_data_converter_main.cc
src/main/user_data_converter_main.h
src/main/unary_filter_main.cc
src/main/unary_filter_main.h
src/main/util_main.h
src/main/write_batch_main.cc
src/main/write_batch_main.h)
# CredentialsProvider has no implementatation on Android and distinct
# implementations for iOS and desktop platforms. On iOS, the implementation of
# the interface actually comes from the FirebaseFirestore CocoaPod, so there's
# no implementation listed here.
set(credentials_provider_desktop_SRCS
src/main/app_check_credentials_provider_desktop.cc
src/main/app_check_credentials_provider_desktop.h
src/main/create_app_check_credentials_provider.h
src/main/create_app_check_credentials_provider_desktop.cc
src/main/create_credentials_provider.h
src/main/create_credentials_provider_desktop.cc
src/main/credentials_provider_desktop.cc
src/main/credentials_provider_desktop.h)
set(credentials_provider_ios_SRCS
src/main/create_app_check_credentials_provider.h
src/main/create_app_check_credentials_provider_ios.mm
src/main/create_credentials_provider.h
src/main/create_credentials_provider_ios.mm)
# FirebaseMetadataProvider has no implementation on Android and distinct
# implementations for iOS and desktop platforms. On iOS, the implementation of
# the interface actually comes from the FirebaseFirestore CocoaPod, so there's
# no implementation listed here.
set(firebase_metadata_provider_desktop_SRCS
src/main/create_firebase_metadata_provider.h
src/main/create_firebase_metadata_provider_desktop.cc
src/main/firebase_metadata_provider_desktop.cc
src/main/firebase_metadata_provider_desktop.h)
set(firebase_metadata_provider_ios_SRCS
src/main/create_firebase_metadata_provider.h
src/main/create_firebase_metadata_provider_ios.mm)
set(wrapper_assertions_SRCS
src/common/wrapper_assertions.cc
src/common/wrapper_assertions.h)
set(ios_only_SRCS
src/main/create_firebase_metadata_provider_ios.mm)
set(desktop_only_SRCS
src/main/create_firebase_metadata_provider_desktop.cc
src/main/firebase_metadata_provider_desktop.cc)
if(ANDROID)
set(firestore_platform_SRCS "${android_SRCS}")
elseif(IOS)
set(firestore_platform_SRCS
"${main_SRCS}"
"${credentials_provider_ios_SRCS}"
"${firebase_metadata_provider_ios_SRCS}")
else()
set(firestore_platform_SRCS
"${main_SRCS}"
"${credentials_provider_desktop_SRCS}"
"${firebase_metadata_provider_desktop_SRCS}")
endif()
add_library(firebase_firestore STATIC
${common_SRCS}
${firestore_platform_SRCS})
set_property(TARGET firebase_firestore PROPERTY FOLDER "Firebase Cpp")
# Set up the dependency on Firebase App.
target_link_libraries(firebase_firestore
PUBLIC
firebase_app
firebase_auth
)
if(FIRESTORE_USE_EXTERNAL_CMAKE_BUILD)
target_link_libraries(firebase_firestore
PUBLIC
firestore_core
absl_variant
)
endif()
# Public C++ headers all refer to each other relative to the src/include
# directory, while private headers are relative to the entire C++ SDK
# directory.
target_include_directories(firebase_firestore
PUBLIC
${CMAKE_CURRENT_LIST_DIR}/src/include
PRIVATE
${FIREBASE_CPP_SDK_ROOT_DIR}
)
# Additional public headers come from the Firestore core
if(IOS)
target_include_directories(firebase_firestore
PUBLIC
# The Firestore core on iOS comes via the FirebaseFirestore CocoaPod, and
# public headers should come from there.
${FIREBASE_POD_DIR}/Pods/FirebaseFirestore/Firestore/core/include
${FIREBASE_POD_DIR}/Pods/FirebaseFirestoreInternal/Firestore/core/include
${FIREBASE_POD_DIR}/Pods/FirebaseFirestore/Firestore/Protos/nanopb
${FIREBASE_POD_DIR}/Pods/FirebaseFirestoreInternal/Firestore/Protos/nanopb
PRIVATE
# Additionally, the core C++ API is not declared publicly within the
# FirebaseFirestore pod, so depend on headers available in the source
# distribution.
${FIREBASE_POD_DIR}/Pods/FirebaseFirestore
${FIREBASE_POD_DIR}/Pods/FirebaseFirestoreInternal
)
set(FIREBASE_FIRESTORE_CORE_HEADER_DIR
${FIREBASE_POD_DIR}/Pods/FirebaseFirestoreInternal/Firestore/core/include
)
else()
# Desktop and Android get their public headers from the CMake build in
# firebase-ios-sdk.
target_include_directories(firebase_firestore
PUBLIC
${FIRESTORE_SOURCE_DIR}/Firestore/core/include
${FIRESTORE_SOURCE_DIR}/Firestore/Protos/nanopb
PRIVATE
${FIRESTORE_SOURCE_DIR}
)
set(FIREBASE_FIRESTORE_CORE_HEADER_DIR
${FIRESTORE_SOURCE_DIR}/Firestore/core/include
)
if(DESKTOP)
target_include_directories(firebase_firestore
PRIVATE
${FLATBUFFERS_SOURCE_DIR}/include
)
endif()
endif()
set(firestore_generated_headers_dir
"${FIREBASE_GEN_FILE_DIR}/firestore/src/include/firebase/firestore")
add_custom_target(
FIREBASE_FIRESTORE_GENERATED_HEADERS
COMMAND ${CMAKE_COMMAND} -E make_directory
"${firestore_generated_headers_dir}"
COMMAND ${CMAKE_COMMAND} -E copy_directory
${FIREBASE_FIRESTORE_CORE_HEADER_DIR}
"${firestore_generated_headers_dir}"
COMMENT "Copying internal Firestore headers"
)
# This is needed due to Firestore's dependence on some firebase::app APIs that
# are guarded by this flag, such as GetUserAgent and function_registry.
set(FIREBASE_FIRESTORE_CPP_DEFINES -DINTERNAL_EXPERIMENTAL=1)
if (MSVC AND NOT ANDROID AND NOT IOS)
# On Windows, gRPC gives a compiler error in firebase_metadata_provider_desktop.cc
# unless _WIN32_WINNT is defined to this value (0x0600, Windows Vista).
# Also set -DNOMINMAX for both Firestore and Firestore Core.
set(FIREBASE_FIRESTORE_CPP_DEFINES ${FIREBASE_FIRESTORE_CPP_DEFINES} -D_WIN32_WINNT=0x0600 -DNOMINMAX)
# Special handling for the absl time zone library, define _LIBCPP_VERSION on
# Windows to avoid the shenanigans they do with Windows mangled symbols to
# accomplish weak linking. See
# https://github.com/google/cctz/blob/master/src/zone_info_source.cc for a
# look at what we're up against.
target_compile_definitions(absl_time_zone
PRIVATE
_LIBCPP_VERSION=99)
endif()
target_compile_definitions(firebase_firestore
PRIVATE
${FIREBASE_FIRESTORE_CPP_DEFINES}
)
# Set the Nanopb preprocessor definitions to match those used by the iOS SDK.
target_compile_definitions(firebase_firestore
PUBLIC -DPB_FIELD_32BIT -DPB_ENABLE_MALLOC -DPB_NO_PACKED_STRUCTS
)
if(ANDROID)
firebase_cpp_proguard_file(firestore)
elseif(IOS)
# Enable Automatic Reference Counting (ARC) and Bitcode.
target_compile_options(firebase_firestore
PUBLIC "-fobjc-arc" "-fembed-bitcode")
target_link_libraries(firebase_firestore
PUBLIC "-fembed-bitcode")
setup_pod_headers(
firebase_firestore
INCLUDE_PRIVATE_HEADERS
POD_NAMES
FirebaseCore
FirebaseFirestore
FirebaseFirestoreInternal
abseil
nanopb
gRPC-C++
gRPC-Core
FirebaseAuthInterop/FirebaseAuth/Interop
FirebaseCoreExtension/FirebaseCore/Extension
)
if (FIREBASE_XCODE_TARGET_FORMAT STREQUAL "frameworks")
set_target_properties(firebase_firestore PROPERTIES
FRAMEWORK TRUE
)
endif()
endif()
cpp_pack_library(firebase_firestore "")
cpp_pack_public_headers()