diff options
author | Gil <mcg@google.com> | 2018-06-26 15:05:28 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-26 15:05:28 -0700 |
commit | 3722deff12ec2e79c479ceae3a829752f92bb710 (patch) | |
tree | b9d779ffe5ead20ffebf988c7f115b35fde428eb /cmake/external/grpc.cmake | |
parent | d03050653ff84e624def93aa512ef35907f5792a (diff) |
Install protobuf during CMake build (#1460)
* Install protobuf
* Use the built-in FindProtobuf.cmake
* Add additional build configuration flags
* Preserve generator configuration in the protobuf sub-build
Without this, the build fails on Win64 because the default
configuration builds a Win32 libprotobuf and the Win64 build rejects
it.
* Wire the installed protobuf into the gRPC build.
* Install nanopb
Diffstat (limited to 'cmake/external/grpc.cmake')
-rw-r--r-- | cmake/external/grpc.cmake | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/cmake/external/grpc.cmake b/cmake/external/grpc.cmake index d192e94..ee4d246 100644 --- a/cmake/external/grpc.cmake +++ b/cmake/external/grpc.cmake @@ -31,8 +31,8 @@ else() set( CMAKE_ARGS -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} - -DgRPC_BUILD_TESTS:BOOL=OFF -DBUILD_SHARED_LIBS:BOOL=OFF + -DgRPC_BUILD_TESTS:BOOL=OFF # TODO(rsgowman): We're currently building nanopb twice; once via grpc, and # once via nanopb. The version from grpc is the one that actually ends up @@ -46,6 +46,29 @@ else() -DCMAKE_CXX_FLAGS=-DPB_FIELD_16BIT ) + + ## 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") + endif() + + list( + APPEND CMAKE_ARGS + -DgRPC_PROTOBUF_PROVIDER:STRING=package + -DgRPC_PROTOBUF_PACKAGE_TYPE:STRING=CONFIG + -DProtobuf_DIR:PATH=${PROTOBUF_CMAKE_DIR} + ) + + + ## zlib + # zlib can be built by grpc but we can avoid it on platforms that provide it # by default. find_package(ZLIB) @@ -62,8 +85,8 @@ else() APPEND GIT_SUBMODULES third_party/zlib ) + endif() - endif(ZLIB_FOUND) ExternalProject_GitSource( GRPC_GIT @@ -74,6 +97,8 @@ else() ExternalProject_Add( grpc + DEPENDS + protobuf ${GRPC_GIT} |