forked from firebase/firebase-ios-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
224 lines (179 loc) · 5.8 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# Copyright 2017 Google
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Superbuild for Firebase
cmake_minimum_required(VERSION 2.8.11)
# Report AppleClang separately from Clang. Their version numbers are different.
# https://cmake.org/cmake/help/v3.0/policy/CMP0025.html
if(POLICY CMP0025)
cmake_policy(SET CMP0025 NEW)
endif()
# Defer enabling any languages.
project(firebase NONE)
if(WIN32)
# On Windows, prefer cl over gcc if both are available. By default most of
# the CMake generators prefer gcc, even on Windows.
set(CMAKE_GENERATOR_CC cl)
endif()
enable_language(C)
enable_language(CXX)
list(INSERT CMAKE_MODULE_PATH 0 ${PROJECT_SOURCE_DIR}/cmake)
include(cc_rules)
include(compiler_id)
include(external_rules)
include(podspec_rules)
include(sanitizer_options)
include(fuzzing_options)
# If no build type is specified, make it a debug build
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()
set(FIREBASE_SOURCE_DIR ${PROJECT_SOURCE_DIR})
set(FIREBASE_BINARY_DIR ${PROJECT_BINARY_DIR})
set(FIREBASE_INSTALL_DIR ${PROJECT_BINARY_DIR}/opt)
set(
FIREBASE_DOWNLOAD_DIR
${PROJECT_BINARY_DIR}/downloads
CACHE PATH "Where to store downloaded files"
)
download_external_sources()
# Googletest
set(gtest_force_shared_crt ON CACHE BOOL "Use shared run-time")
add_external_subdirectory(googletest)
add_alias(GTest::GTest gtest)
add_alias(GTest::Main gtest_main)
add_alias(GMock::GMock gmock)
# Benchmark
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "Firestore disabled")
set(BENCHMARK_ENABLE_EXCEPTIONS OFF CACHE BOOL "Firestore disabled")
set(BENCHMARK_ENABLE_INSTALL OFF CACHE BOOL "Firestore disabled")
set(BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE BOOL "Firestore disabled")
add_external_subdirectory(benchmark)
# Abseil-cpp
# Force disable Abseil's tests, which don't compile under VS2017.
set(old_build_testing ${BUILD_TESTING})
set(BUILD_TESTING OFF CACHE BOOL "Disable Abseil tests" FORCE)
add_subdirectory(
Firestore/third_party/abseil-cpp
)
set(BUILD_TESTING ${old_build_testing} CACHE BOOL "Restore BUILD_TESTING" FORCE)
# gRPC
find_package(OpenSSL)
if(OPENSSL_FOUND)
set(gRPC_SSL_PROVIDER package CACHE STRING "Use external OpenSSL")
endif()
find_package(ZLIB)
if(ZLIB_FOUND)
set(gRPC_ZLIB_PROVIDER package CACHE STRING "Use external ZLIB")
endif()
set(gRPC_BUILD_TESTS OFF CACHE BOOL "Disable gRPC tests")
add_external_subdirectory(grpc)
# Fix up targets included by gRPC's build
set(external_src_dir ${FIREBASE_BINARY_DIR}/external/src)
if(OPENSSL_FOUND)
# gRPC's CMakeLists.txt does not account for finding OpenSSL in a directory
# that's not in the default search path.
target_include_directories(grpc PRIVATE ${OPENSSL_INCLUDE_DIR})
if(CXX_CLANG OR CXX_GNU)
if((OPENSSL_VERSION VERSION_EQUAL "1.1.0") OR
(OPENSSL_VERSION VERSION_GREATER "1.1.0"))
# gRPC uses some features deprecated in OpenSSL 1.1.0
target_compile_options(
grpc
PRIVATE -Wno-deprecated-declarations
)
endif()
endif()
else()
# Not using outboard OpenSSL so set up BoringSSL to look like it.
add_alias(OpenSSL::Crypto crypto)
target_include_directories(
crypto
INTERFACE
$<BUILD_INTERFACE:${external_src_dir}/grpc/third_party/boringssl/include>
)
add_alias(OpenSSL::SSL ssl)
target_include_directories(
ssl
INTERFACE
$<BUILD_INTERFACE:${external_src_dir}/grpc/third_party/boringssl/include>
)
endif()
add_alias(protobuf::libprotobuf libprotobuf)
if(CXX_CLANG OR CXX_GNU)
target_compile_options(
libprotobuf
PUBLIC -Wno-unused-parameter
)
endif()
if(CXX_CLANG)
target_compile_options(
libprotobuf
PRIVATE -Wno-invalid-offsetof
)
endif()
if(NOT ZLIB_FOUND)
target_include_directories(
zlibstatic
INTERFACE $<BUILD_INTERFACE:${external_src_dir}/grpc/third_party/zlib>
)
endif()
# LevelDB
if(NOT WIN32)
set(HAVE_LEVELDB ON)
endif()
if(HAVE_LEVELDB)
set(LEVELDB_BUILD_TESTS OFF CACHE BOOL "Firestore disabled")
set(LEVELDB_BUILD_BENCHMARKS OFF CACHE BOOL "Firestore disabled")
set(LEVELDB_INSTALL OFF CACHE BOOL "Firestore disabled")
add_external_subdirectory(leveldb)
add_alias(LevelDB::LevelDB leveldb)
endif()
# nanopb
set(nanopb_BUILD_GENERATOR ON CACHE BOOL "Enable the nanopb generator")
set(nanopb_MSVC_STATIC_RUNTIME OFF CACHE BOOL "Link static runtime libraries")
add_external_subdirectory(nanopb)
target_compile_definitions(
protobuf-nanopb
PUBLIC -DPB_FIELD_32BIT -DPB_ENABLE_MALLOC
)
target_include_directories(
protobuf-nanopb
INTERFACE $<BUILD_INTERFACE:${external_src_dir}/nanopb>
)
enable_testing()
include(compiler_setup)
# Firebase packages
podspec_framework(
${FIREBASE_SOURCE_DIR}/GoogleUtilities.podspec
SPECS Logger
)
podspec_framework(${FIREBASE_SOURCE_DIR}/FirebaseCore.podspec)
podspec_framework(${FIREBASE_SOURCE_DIR}/FirebaseAuthInterop.podspec)
if(APPLE)
# FirebaseAuthInterop has no source files but CMake can't build frameworks
# that don't have sources. Generate an inconsequential source file so that
# the library can be linked.
file(
WRITE ${CMAKE_CURRENT_BINARY_DIR}/FirebaseAuthInteropDummy.c
"// generated file for header-only CMake support.
__attribute__((unused))
static void FirebaseAuthInteropFakeSymbol() {}
"
)
target_sources(
FirebaseAuthInterop
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/FirebaseAuthInteropDummy.c
)
endif()
add_subdirectory(Firestore)