@@ -61,26 +61,80 @@ endfunction()
61
61
# target
62
62
# SOURCES sources...
63
63
# DEPENDS libraries...
64
+ # CUSTOM_FRAMEWORKS frameworks...
64
65
# )
65
66
#
66
67
# Defines a new test executable target with the given target name, sources, and
67
68
# 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.
69
71
function (cc_test_on_ios name )
70
72
if (NOT IOS)
71
73
return ()
72
74
endif ()
73
75
74
- set (multi DEPENDS SOURCES INCLUDES DEFINES)
76
+ set (multi DEPENDS SOURCES INCLUDES DEFINES CUSTOM_FRAMEWORKS )
75
77
# Parse the arguments into cc_test_SOURCES and cc_test_DEPENDS.
76
78
cmake_parse_arguments (cc_test "" "" "${multi} " ${ARGN} )
77
79
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
+
78
130
list (APPEND cc_test_DEPENDS
79
131
gmock
80
132
gtest
81
133
gtest_main
134
+ "${FRAMEWORK_DIRS} "
82
135
"-framework CoreFoundation"
83
136
"-framework Foundation"
137
+ "${FRAMEWORK_INCLUDES} "
84
138
)
85
139
86
140
add_executable (${name} ${cc_test_SOURCES} )
0 commit comments