aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Gil <mcg@google.com>2018-06-28 14:03:52 -0700
committerGravatar GitHub <noreply@github.com>2018-06-28 14:03:52 -0700
commitb8eb4e04497a5d51343e94465fd01b39a520c29c (patch)
tree7dd8dbe40db86229523afdaa296b6c7673dbbeb1
parent74fa22f1de418d5389b5a68e379a689516c3980b (diff)
Add a CMake external build for c-ares (#1472)
* Add an external build for c-ares * Use installed c-ares package configuration * Adjust protobuf configuration to use the standard Protobuf_DIR variable. * Have grpc depend on c-ares * Drop UPDATE_COMMAND where it doesn't matter
-rw-r--r--CMakeLists.txt1
-rw-r--r--cmake/FindGRPC.cmake18
-rw-r--r--cmake/external/c-ares.cmake34
-rw-r--r--cmake/external/googletest.cmake1
-rw-r--r--cmake/external/grpc.cmake26
-rw-r--r--cmake/external/leveldb.cmake1
-rw-r--r--cmake/external/nanopb.cmake1
-rw-r--r--cmake/external/protobuf.cmake1
-rw-r--r--cmake/external/zlib.cmake1
9 files changed, 59 insertions, 25 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 84722d8..a935c4d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -56,5 +56,6 @@ include(external/zlib)
include(external/leveldb)
include(external/protobuf)
include(external/nanopb)
+include(external/c-ares)
include(external/grpc)
include(external/firestore)
diff --git a/cmake/FindGRPC.cmake b/cmake/FindGRPC.cmake
index 22c9655..ba8f857 100644
--- a/cmake/FindGRPC.cmake
+++ b/cmake/FindGRPC.cmake
@@ -56,20 +56,10 @@ find_package(OpenSSL REQUIRED)
## C-Ares
-find_library(
- CARES_LIBRARY
- NAMES cares
- HINTS ${BINARY_DIR}/src/grpc-build/third_party/cares/cares/lib
-)
-if(NOT (CARES_LIBRARY STREQUAL "CARES_LIBRARY-NOTFOUND"))
- if (NOT TARGET c-ares::ares)
- add_library(c-ares::ares UNKNOWN IMPORTED)
- set_target_properties(
- c-ares::ares PROPERTIES
- IMPORTED_LOCATION ${CARES_LIBRARY}
- )
- endif()
+if(NOT c-ares_DIR)
+ set(c-ares_DIR ${FIREBASE_INSTALL_DIR}/lib/cmake/c-ares)
endif()
+find_package(c-ares CONFIG REQUIRED)
## GRPC
@@ -124,7 +114,7 @@ if(GRPC_FOUND)
if (NOT TARGET grpc::grpc)
set(
GRPC_LINK_LIBRARIES
- c-ares::ares
+ c-ares::cares
grpc::gpr
OpenSSL::SSL
OpenSSL::Crypto
diff --git a/cmake/external/c-ares.cmake b/cmake/external/c-ares.cmake
new file mode 100644
index 0000000..4c866c1
--- /dev/null
+++ b/cmake/external/c-ares.cmake
@@ -0,0 +1,34 @@
+# Copyright 2018 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.
+
+include(ExternalProject)
+
+ExternalProject_Add(
+ c-ares
+
+ DOWNLOAD_DIR ${FIREBASE_DOWNLOAD_DIR}
+ URL https://github.com/c-ares/c-ares/archive/cares-1_14_0.tar.gz
+ URL_HASH SHA256=62dd12f0557918f89ad6f5b759f0bf4727174ae9979499f5452c02be38d9d3e8
+
+ PREFIX ${PROJECT_BINARY_DIR}/external/cares
+
+ CMAKE_ARGS
+ -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
+ -DCMAKE_INSTALL_PREFIX:STRING=${FIREBASE_INSTALL_DIR}
+ -DCARES_STATIC:BOOL=ON
+ -DCARES_SHARED:BOOL=OFF
+ -DCARES_STATIC_PIC:BOOL=ON
+
+ TEST_COMMAND ""
+)
diff --git a/cmake/external/googletest.cmake b/cmake/external/googletest.cmake
index 3af136e..b80c098 100644
--- a/cmake/external/googletest.cmake
+++ b/cmake/external/googletest.cmake
@@ -27,6 +27,5 @@ ExternalProject_Add(
CMAKE_CACHE_ARGS
-DCMAKE_INSTALL_PREFIX:STRING=${FIREBASE_INSTALL_DIR}
- UPDATE_COMMAND ""
TEST_COMMAND ""
)
diff --git a/cmake/external/grpc.cmake b/cmake/external/grpc.cmake
index 1e8388c..a789838 100644
--- a/cmake/external/grpc.cmake
+++ b/cmake/external/grpc.cmake
@@ -24,7 +24,6 @@ else()
set(
GIT_SUBMODULES
third_party/boringssl
- third_party/cares/cares
)
set(
@@ -46,23 +45,37 @@ else()
)
+ ## c-ares
+ if(NOT c-ares_DIR)
+ set(c-ares_DIR ${FIREBASE_INSTALL_DIR}/lib/cmake/c-ares)
+ endif()
+
+ list(
+ APPEND CMAKE_ARGS
+ -DgRPC_CARES_PROVIDER:STRING=package
+ -Dc-ares_DIR:PATH=${c-ares_DIR}
+ )
+
+
## protobuf
# Unlike other dependencies of gRPC, we control the protobuf version because we
# have checked-in protoc outputs that must match the runtime.
# The location where protobuf-config.cmake will be installed varies by platform
- if (WIN32)
- set(PROTOBUF_CMAKE_DIR "${FIREBASE_INSTALL_DIR}/cmake")
- else()
- set(PROTOBUF_CMAKE_DIR "${FIREBASE_INSTALL_DIR}/lib/cmake/protobuf")
+ if(NOT Protobuf_DIR)
+ if(WIN32)
+ set(Protobuf_DIR "${FIREBASE_INSTALL_DIR}/cmake")
+ else()
+ set(Protobuf_DIR "${FIREBASE_INSTALL_DIR}/lib/cmake/protobuf")
+ endif()
endif()
list(
APPEND CMAKE_ARGS
-DgRPC_PROTOBUF_PROVIDER:STRING=package
-DgRPC_PROTOBUF_PACKAGE_TYPE:STRING=CONFIG
- -DProtobuf_DIR:PATH=${PROTOBUF_CMAKE_DIR}
+ -DProtobuf_DIR:PATH=${Protobuf_DIR}
)
@@ -94,6 +107,7 @@ else()
ExternalProject_Add(
grpc
DEPENDS
+ c-ares
protobuf
zlib
diff --git a/cmake/external/leveldb.cmake b/cmake/external/leveldb.cmake
index db8aa4c..9daab02 100644
--- a/cmake/external/leveldb.cmake
+++ b/cmake/external/leveldb.cmake
@@ -66,7 +66,6 @@ else()
INSTALL_DIR ${FIREBASE_INSTALL_DIR}
- UPDATE_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)
diff --git a/cmake/external/nanopb.cmake b/cmake/external/nanopb.cmake
index 39eb833..b5c74ce 100644
--- a/cmake/external/nanopb.cmake
+++ b/cmake/external/nanopb.cmake
@@ -34,6 +34,5 @@ ExternalProject_Add(
-Dnanopb_BUILD_GENERATOR:BOOL=ON
-Dnanopb_PROTOC_PATH:STRING=${NANOPB_PROTOC_BIN}
- UPDATE_COMMAND ""
TEST_COMMAND ""
)
diff --git a/cmake/external/protobuf.cmake b/cmake/external/protobuf.cmake
index 66d1426..e8060b2 100644
--- a/cmake/external/protobuf.cmake
+++ b/cmake/external/protobuf.cmake
@@ -105,6 +105,5 @@ ExternalProject_Add(
${commands}
- UPDATE_COMMAND ""
TEST_COMMAND ""
)
diff --git a/cmake/external/zlib.cmake b/cmake/external/zlib.cmake
index 4744fe9..a90a511 100644
--- a/cmake/external/zlib.cmake
+++ b/cmake/external/zlib.cmake
@@ -35,7 +35,6 @@ else()
-DCMAKE_INSTALL_PREFIX:STRING=${FIREBASE_INSTALL_DIR}
-DBUILD_SHARED_LIBS:BOOL=OFF
- UPDATE_COMMAND ""
TEST_COMMAND ""
)
endif()