Skip to content

Commit c1cb80c

Browse files
authored
Make shared libraries link against the universal one (#259)
* Make shared libraries link against the universal one * Add special logic needed by Firestore
1 parent 3f6aa29 commit c1cb80c

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

cmake/build_shared.cmake

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,25 @@ function(build_firebase_shared LIBRARY_NAME ARTIFACT_NAME OUTPUT_NAME)
3535

3636
set(shared_target "firebase_${LIBRARY_NAME}_shared")
3737

38-
add_library(${shared_target} SHARED
39-
${FIREBASE_SOURCE_DIR}/empty.cc
40-
$<TARGET_OBJECTS:firebase_${LIBRARY_NAME}>
41-
$<TARGET_OBJECTS:firebase_${LIBRARY_NAME}_swig>
42-
)
43-
44-
set(SHARED_TARGET_LINK_LIB_NAMES "firebase_${LIBRARY_NAME}" "firebase_${LIBRARY_NAME}_swig")
38+
if(FIREBASE_IOS_BUILD OR NOT FIREBASE_UNI_LIBRARY)
39+
# On iOS, we want to include all the symbols in the library
40+
add_library(${shared_target} SHARED
41+
${FIREBASE_SOURCE_DIR}/empty.cc
42+
$<TARGET_OBJECTS:firebase_${LIBRARY_NAME}>
43+
$<TARGET_OBJECTS:firebase_${LIBRARY_NAME}_swig>
44+
)
45+
46+
set(SHARED_TARGET_LINK_LIB_NAMES "firebase_${LIBRARY_NAME}" "firebase_${LIBRARY_NAME}_swig")
47+
else()
48+
# On other platforms, we only want the symbols from the
49+
# generated swig C++ file, and then linked against the
50+
# universal library, which has the symbols we need
51+
add_library(${shared_target} SHARED
52+
${firebase_${LIBRARY_NAME}_swig_gen_cpp_src}
53+
)
54+
55+
set(SHARED_TARGET_LINK_LIB_NAMES "firebase_app_uni")
56+
endif()
4557

4658
target_link_libraries(${shared_target}
4759
${SHARED_TARGET_LINK_LIB_NAMES}

cmake/firebase_swig.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,5 +258,8 @@ macro(firebase_swig_add_library name)
258258
)
259259

260260
set(${name}_gen_src ${UNITY_SWIG_CS_FIX_FILE})
261+
# Set a variable so that the C++ file can be referenced elsewhere
262+
set(${name}_gen_cpp_src ${UNITY_SWIG_CPP_FIX_FILE})
263+
set(${name}_gen_cpp_src ${UNITY_SWIG_CPP_FIX_FILE} PARENT_SCOPE)
261264

262265
endmacro()

firestore/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,14 @@ else()
150150
firestore
151151
FirebaseCppFirestore
152152
)
153+
154+
target_include_directories(firebase_firestore_shared
155+
PUBLIC
156+
${FIRESTORE_SOURCE_DIR}/Firestore/core/include
157+
${FIRESTORE_SOURCE_DIR}/Firestore/Protos/nanopb
158+
PRIVATE
159+
${FIRESTORE_SOURCE_DIR}
160+
)
153161
endif()
154162

155163
unity_pack_cs(firebase_firestore_cs)

0 commit comments

Comments
 (0)