@@ -61,26 +61,80 @@ endfunction()
6161# target
6262# SOURCES sources...
6363# DEPENDS libraries...
64+ # CUSTOM_FRAMEWORKS frameworks...
6465# )
6566#
6667# Defines a new test executable target with the given target name, sources, and
6768# dependencies. Implicitly adds DEPENDS on gtest, gtest_main, Foundation and
68- # CoreFoundation frameworks.
69+ # CoreFoundation frameworks. CUSTOM_FRAMEWORKS will include any custom Cocoapods
70+ # frameworks beyond the baseline FirebaseAnalytics.
6971function (cc_test_on_ios name )
7072 if (NOT IOS)
7173 return ()
7274 endif ()
7375
74- set (multi DEPENDS SOURCES INCLUDES DEFINES)
76+ set (multi DEPENDS SOURCES INCLUDES DEFINES CUSTOM_FRAMEWORKS )
7577 # Parse the arguments into cc_test_SOURCES and cc_test_DEPENDS.
7678 cmake_parse_arguments (cc_test "" "" "${multi} " ${ARGN} )
7779
80+ set (SDK_FRAMEWORK_DIR_NAMES
81+ FirebaseABTesting
82+ FirebaseAnalytics
83+ FirebaseAuth
84+ FirebaseDatabase
85+ FirebaseDynamicLinks
86+ FirebaseFunctions
87+ FirebaseMessaging
88+ FirebaseRemoteConfig
89+ FirebaseStorage
90+ GoogleSignIn
91+ )
92+
93+ # The build environment can use a user-downloaded Firebase IOS SDK defined by
94+ # FIREBASE_IOS_SDK_DIR. Alternatively download the SDK directly if it's not
95+ # configured and store the files in external/firebase_ios_sdk.
96+ if (NOT DEFINED ${FIREBASE_IOS_SDK_DIR} )
97+ set (FIREBASE_IOS_SDK_DIR
98+ "${CMAKE_BINARY_DIR} /external/firebase_ios_sdk/Firebase" )
99+ endif ()
100+
101+ # Add the directories of the SDK download to the framework searchpath.
102+ foreach (FRAMEWORK IN LISTS SDK_FRAMEWORK_DIR_NAMES)
103+ set (directory "${FIREBASE_IOS_SDK_DIR} /${FRAMEWORK} " )
104+ LIST (APPEND FRAMEWORK_DIRS "-F ${directory} " )
105+ endforeach ()
106+
107+ # All Firebase SDK modules require the Firebase Analytics Frameworks
108+ # so include them by default:
109+ set (DEFAULT_FRAMEWORKS
110+ FIRAnalyticsConnector
111+ FirebaseAnalytics
112+ FirebaseCore
113+ FirebaseCoreDiagnostics
114+ FirebaseInstanceID
115+ GTMSessionFetcher
116+ GoogleAppMeasurement
117+ GoogleDataTransport
118+ GoogleDataTransportCCTSupport
119+ GoogleUtilities
120+ nanopb
121+ )
122+
123+ # Construct a command line list of frameworks from the default frameworks
124+ # (above) and for those passed to this function through the CUSTOM_FRAMEWORKS
125+ # parameter.
126+ foreach (FRAMEWORK IN LISTS DEFAULT_FRAMEWORKS cc_test_CUSTOM_FRAMEWORKS)
127+ LIST (APPEND FRAMEWORK_INCLUDES "-framework ${FRAMEWORK} " )
128+ endforeach ()
129+
78130 list (APPEND cc_test_DEPENDS
79131 gmock
80132 gtest
81133 gtest_main
134+ "${FRAMEWORK_DIRS} "
82135 "-framework CoreFoundation"
83136 "-framework Foundation"
137+ "${FRAMEWORK_INCLUDES} "
84138 )
85139
86140 add_executable (${name} ${cc_test_SOURCES} )
0 commit comments