From cda87fa3afdacf20a097cf6ed90c5c2ef64e0437 Mon Sep 17 00:00:00 2001 From: Gil Date: Mon, 16 Jul 2018 08:50:53 -0700 Subject: Convert grpc and protobuf CMake builds to add_subdirectory (#1537) * Build zlib with grpc's add_subdirectory * Build grpc and its children with add_subdirectory. * Build c-ares with grpc's add_subdirectory * Convert protobuf to a download-only ExternalProject * Temporarily break protobuf within grpc This works because libgrpc has no actual dependency on protobuf * Update boringssl to master@{2018-07-10} --- Firestore/CMakeLists.txt | 45 +++++++++++++++++++++- Firestore/Protos/CMakeLists.txt | 5 --- .../src/firebase/firestore/remote/CMakeLists.txt | 2 +- 3 files changed, 44 insertions(+), 8 deletions(-) (limited to 'Firestore') diff --git a/Firestore/CMakeLists.txt b/Firestore/CMakeLists.txt index cbcd49d..039cb06 100644 --- a/Firestore/CMakeLists.txt +++ b/Firestore/CMakeLists.txt @@ -42,9 +42,8 @@ if(APPLE) find_package(FirebaseCore REQUIRED) find_package(GoogleUtilities REQUIRED) endif() -find_package(GRPC REQUIRED) find_package(LevelDB REQUIRED) -find_package(Protobuf REQUIRED) +find_package(ZLIB) # Googletest @@ -64,6 +63,48 @@ add_subdirectory( ) +# gRPC +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_subdirectory( + ${FIREBASE_BINARY_DIR}/src/grpc + ${FIREBASE_BINARY_DIR}/src/grpc-build + EXCLUDE_FROM_ALL +) + +# Fix up targets included by gRPC's build +add_alias(OpenSSL::Crypto crypto) +target_include_directories( + crypto + INTERFACE + $ +) + +add_alias(OpenSSL::SSL ssl) +target_include_directories( + ssl + INTERFACE + $ +) + +add_alias(protobuf::libprotobuf libprotobuf) +target_compile_options( + libprotobuf + PUBLIC -Wno-unused-parameter +) + +if(NOT ZLIB_FOUND) + target_include_directories( + zlibstatic + INTERFACE + $ + ) +endif() + + # nanopb set(nanopb_BUILD_GENERATOR ON CACHE BOOL "Enable the nanopb generator") set(nanopb_PROTOC_PATH ${NANOPB_PROTOC_BIN} CACHE STRING "Protoc location") diff --git a/Firestore/Protos/CMakeLists.txt b/Firestore/Protos/CMakeLists.txt index 214c15f..c2132ae 100644 --- a/Firestore/Protos/CMakeLists.txt +++ b/Firestore/Protos/CMakeLists.txt @@ -97,8 +97,3 @@ target_include_directories( firebase_firestore_protos_libprotobuf PUBLIC ${FIREBASE_SOURCE_DIR}/Firestore/Protos/cpp ) - -set_target_properties( - firebase_firestore_protos_libprotobuf - PROPERTIES COMPILE_FLAGS "-Wno-unused-parameter" -) diff --git a/Firestore/core/src/firebase/firestore/remote/CMakeLists.txt b/Firestore/core/src/firebase/firestore/remote/CMakeLists.txt index af62ab1..5de4648 100644 --- a/Firestore/core/src/firebase/firestore/remote/CMakeLists.txt +++ b/Firestore/core/src/firebase/firestore/remote/CMakeLists.txt @@ -29,5 +29,5 @@ cc_library( firebase_firestore_nanopb firebase_firestore_protos_nanopb firebase_firestore_util - grpc::grpc + grpc ) -- cgit v1.2.3