@@ -39,6 +39,9 @@ option(FIREBASE_INCLUDE_DATABASE
39
39
option (FIREBASE_INCLUDE_DYNAMIC_LINKS
40
40
"Include the Firebase Dynamic Links library."
41
41
${FIREBASE_INCLUDE_LIBRARY_DEFAULT} )
42
+ option (FIREBASE_INCLUDE_FIRESTORE
43
+ "Include the Cloud Firestore library."
44
+ ${FIREBASE_INCLUDE_LIBRARY_DEFAULT} )
42
45
option (FIREBASE_INCLUDE_FUNCTIONS
43
46
"Include the Cloud Functions for Firebase library."
44
47
${FIREBASE_INCLUDE_LIBRARY_DEFAULT} )
@@ -122,6 +125,22 @@ else()
122
125
message (STATUS "Downloading external project dependencies..." )
123
126
download_external_sources ()
124
127
message (STATUS "Download complete." )
128
+
129
+ # Include Firestore's external build early to resolve conflicts on packages.
130
+ if (FIREBASE_INCLUDE_FIRESTORE )
131
+ set (FIRESTORE_SOURCE_DIR ${FIREBASE_BINARY_DIR} /external/src/firestore )
132
+ set (FIRESTORE_BINARY_DIR ${FIRESTORE_SOURCE_DIR} -build )
133
+
134
+ set (
135
+ FIREBASE_IOS_BUILD_TESTS
136
+ ${FIREBASE_CPP_BUILD_TESTS}
137
+ CACHE BOOL "Force Firestore build tests to match"
138
+ )
139
+
140
+ add_subdirectory (${FIRESTORE_SOURCE_DIR} ${FIRESTORE_BINARY_DIR} )
141
+
142
+ copy_subdirectory_definition (${FIRESTORE_SOURCE_DIR} NANOPB_SOURCE_DIR )
143
+ endif ()
125
144
endif ()
126
145
127
146
# Disable the Flatbuffer build tests, install and flathash
@@ -142,9 +161,9 @@ else()
142
161
add_external_library (flatbuffers )
143
162
endif ()
144
163
145
- if (FIREBASE_CPP_BUILD_TESTS )
164
+ if (FIREBASE_CPP_BUILD_TESTS AND NOT FIREBASE_INCLUDE_FIRESTORE )
165
+ # Firestore's external build pulls in googletest
146
166
add_external_library (googletest )
147
- add_external_library (absl )
148
167
endif ()
149
168
150
169
# Some of the external libraries are not used for mobile.
@@ -231,15 +250,30 @@ if (NOT ANDROID AND NOT IOS)
231
250
zlibstatic
232
251
)
233
252
endif ()
253
+ endif ()
254
+
255
+ if (FIREBASE_INCLUDE_FIRESTORE )
256
+ # The Firestore build includes protobuf and nanopb already
257
+ list (APPEND CMAKE_MODULE_PATH ${NANOPB_SOURCE_DIR} /extra )
258
+ find_package (Nanopb REQUIRED )
234
259
260
+ set (PROTOBUF_FOUND ON )
261
+
262
+ else ()
235
263
find_package (Protobuf )
236
264
if (PROTOBUF_FOUND )
237
265
# NanoPB requires Protobuf to be present, so only add it if it was found.
238
266
add_external_library (nanopb )
267
+
239
268
# NanoPB has a FindNanopb which defines the function to generate files, so
240
269
# add it to the module path, and use that.
241
- list (INSERT CMAKE_MODULE_PATH 0 ${NANOPB_SOURCE_DIR} /extra )
270
+ list (APPEND CMAKE_MODULE_PATH ${NANOPB_SOURCE_DIR} /extra )
242
271
find_package (Nanopb )
272
+
273
+ target_compile_definitions (
274
+ protobuf-nanopb-static
275
+ PUBLIC -DPB_FIELD_32BIT -DPB_ENABLE_MALLOC
276
+ )
243
277
endif ()
244
278
endif ()
245
279
@@ -352,6 +386,9 @@ endif()
352
386
if (FIREBASE_INCLUDE_DYNAMIC_LINKS )
353
387
add_subdirectory (dynamic_links )
354
388
endif ()
389
+ if (FIREBASE_INCLUDE_FIRESTORE )
390
+ add_subdirectory (firestore )
391
+ endif ()
355
392
if (FIREBASE_INCLUDE_FUNCTIONS )
356
393
add_subdirectory (functions )
357
394
endif ()
0 commit comments