@@ -20,32 +20,43 @@ set (CMAKE_CXX_STANDARD 11)
20
20
# Turn on virtual folders for visual studio
21
21
set_property (GLOBAL PROPERTY USE_FOLDERS ON )
22
22
23
+ # Top level option that determines the default behavior of the include options
24
+ # below. Useful for turning off all at once, and then turning on a specific one.
25
+ option (FIREBASE_INCLUDE_LIBRARY_DEFAULT
26
+ "Should each library be included by default." ON )
23
27
# Different options to enable/disable each library being included during
24
28
# configuration.
25
- option (FIREBASE_INCLUDE_ADMOB "Include the AdMob library." ON )
29
+ option (FIREBASE_INCLUDE_ADMOB "Include the AdMob library."
30
+ ${FIREBASE_INCLUDE_LIBRARY_DEFAULT} )
26
31
option (FIREBASE_INCLUDE_ANALYTICS
27
- "Include the Google Analytics for Firebase library." ON )
28
- option (FIREBASE_INCLUDE_AUTH "Include the Firebase Authentication library." ON )
32
+ "Include the Google Analytics for Firebase library."
33
+ ${FIREBASE_INCLUDE_LIBRARY_DEFAULT} )
34
+ option (FIREBASE_INCLUDE_AUTH "Include the Firebase Authentication library."
35
+ ${FIREBASE_INCLUDE_LIBRARY_DEFAULT} )
29
36
option (FIREBASE_INCLUDE_DATABASE
30
- "Include the Firebase Realtime Database library." ON )
37
+ "Include the Firebase Realtime Database library."
38
+ ${FIREBASE_INCLUDE_LIBRARY_DEFAULT} )
31
39
option (FIREBASE_INCLUDE_DYNAMIC_LINKS
32
- "Include the Firebase Dynamic Links library." ON )
40
+ "Include the Firebase Dynamic Links library."
41
+ ${FIREBASE_INCLUDE_LIBRARY_DEFAULT} )
33
42
option (FIREBASE_INCLUDE_FUNCTIONS
34
- "Include the Cloud Functions for Firebase library." ON )
43
+ "Include the Cloud Functions for Firebase library."
44
+ ${FIREBASE_INCLUDE_LIBRARY_DEFAULT} )
35
45
option (FIREBASE_INCLUDE_INSTANCE_ID
36
- "Include the Firebase Instance ID library." ON )
46
+ "Include the Firebase Instance ID library."
47
+ ${FIREBASE_INCLUDE_LIBRARY_DEFAULT} )
37
48
option (FIREBASE_INCLUDE_MESSAGING
38
- "Include the Firebase Cloud Messaging library." ON )
49
+ "Include the Firebase Cloud Messaging library."
50
+ ${FIREBASE_INCLUDE_LIBRARY_DEFAULT} )
39
51
option (FIREBASE_INCLUDE_REMOTE_CONFIG
40
- "Include the Firebase Remote Config library." ON )
52
+ "Include the Firebase Remote Config library."
53
+ ${FIREBASE_INCLUDE_LIBRARY_DEFAULT} )
41
54
option (FIREBASE_INCLUDE_STORAGE
42
- "Include the Cloud Storage for Firebase library." ON )
43
- option (FIREBASE_CPP_BUILD_TESTS
44
- "Enable the Firebase C++ Build Tests." OFF )
45
- option (FIREBASE_FORCE_FAKE_SECURE_STORAGE
46
- "Disable use of platform secret store and use fake impl." OFF )
47
- option (FIREBASE_CPP_BUILD_PACKAGE
48
- "Bundle the Firebase C++ libraries into a zip file." OFF )
55
+ "Include the Cloud Storage for Firebase library."
56
+ ${FIREBASE_INCLUDE_LIBRARY_DEFAULT} )
57
+
58
+ option (FIREBASE_CPP_USE_PRIOR_GRADLE_BUILD
59
+ "When building with Gradle, use the previously built libraries." OFF )
49
60
50
61
# Define this directory to be the root of the C++ SDK, which the libraries can
51
62
# then refer to.
@@ -94,10 +105,18 @@ set(FIREBASE_BINARY_DIR ${PROJECT_BINARY_DIR})
94
105
set (FIREBASE_INSTALL_DIR ${PROJECT_BINARY_DIR} /opt )
95
106
set (FIREBASE_DOWNLOAD_DIR ${PROJECT_BINARY_DIR} /downloads )
96
107
97
- # Run the CMake build logic that will download all the external dependencies.
98
- message (STATUS "Downloading external project dependencies..." )
99
- download_external_sources ()
100
- message (STATUS "Download complete." )
108
+ if (FIREBASE_CPP_USE_PRIOR_GRADLE_BUILD )
109
+ # Figure out where app's binary_dir was.
110
+ string (REGEX REPLACE
111
+ "${CMAKE_CURRENT_LIST_DIR} /[^/]+/(.*)"
112
+ "${CMAKE_CURRENT_LIST_DIR} /app/\\ 1"
113
+ APP_BINARY_DIR "${FIREBASE_BINARY_DIR} " )
114
+ else ()
115
+ # Run the CMake build logic that will download all the external dependencies.
116
+ message (STATUS "Downloading external project dependencies..." )
117
+ download_external_sources ()
118
+ message (STATUS "Download complete." )
119
+ endif ()
101
120
102
121
# Disable the Flatbuffer build tests, install and flathash
103
122
set (FLATBUFFERS_BUILD_TESTS OFF CACHE BOOL "" )
@@ -109,9 +128,13 @@ if(IOS OR ANDROID)
109
128
set (FLATBUFFERS_BUILD_FLATC OFF CACHE BOOL "" )
110
129
endif ()
111
130
112
- # Add flatbuffers as a subdirectory, and set the directory variables for it,
113
- # so that the sub Firebase projects can depend upon it if necessary.
114
- add_external_library (flatbuffers )
131
+ if (FIREBASE_CPP_USE_PRIOR_GRADLE_BUILD )
132
+ message (STATUS "flatbuffers is added with APP_BINARY_DIR ${APP_BINARY_DIR} " )
133
+ add_external_library (flatbuffers BINARY_DIR "${APP_BINARY_DIR} " )
134
+ else ()
135
+ message (STATUS "flatbuffers is added normally" )
136
+ add_external_library (flatbuffers )
137
+ endif ()
115
138
116
139
if (FIREBASE_CPP_BUILD_TESTS )
117
140
add_external_library (googletest )
@@ -290,8 +313,24 @@ if(FIREBASE_CPP_BUILD_TESTS)
290
313
add_subdirectory (testing )
291
314
endif ()
292
315
293
- # App needs to come first, since other libraries will depend upon it.
294
- add_subdirectory (app )
316
+ if (NOT FIREBASE_CPP_USE_PRIOR_GRADLE_BUILD )
317
+ add_subdirectory (app )
318
+ else ()
319
+ # Add firebase_app as a target on the previously built app.
320
+ add_library (firebase_app STATIC IMPORTED GLOBAL )
321
+ file (MAKE_DIRECTORY "${APP_BINARY_DIR} /generated" )
322
+ file (MAKE_DIRECTORY "${FIREBASE_BINARY_DIR} /generated" )
323
+ set (app_include_dirs
324
+ "${CMAKE_CURRENT_LIST_DIR} /app/src/include"
325
+ "${APP_BINARY_DIR} /generated"
326
+ "${FIREBASE_BINARY_DIR} /generated"
327
+ )
328
+ set_target_properties (firebase_app PROPERTIES
329
+ IMPORTED_LOCATION "${APP_BINARY_DIR} /libfirebase_app.a"
330
+ INTERFACE_INCLUDE_DIRECTORIES "${app_include_dirs} "
331
+ )
332
+ endif ()
333
+
295
334
if (FIREBASE_INCLUDE_ADMOB )
296
335
add_subdirectory (admob )
297
336
endif ()
0 commit comments