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} --- cmake/external/protobuf.cmake | 89 +++++-------------------------------------- 1 file changed, 9 insertions(+), 80 deletions(-) (limited to 'cmake/external/protobuf.cmake') diff --git a/cmake/external/protobuf.cmake b/cmake/external/protobuf.cmake index 2cc632c..b85255e 100644 --- a/cmake/external/protobuf.cmake +++ b/cmake/external/protobuf.cmake @@ -18,86 +18,14 @@ if(TARGET protobuf) return() endif() -# Protubuf has CMake support, but includes it in a `cmake` subdirectory, which -# does not work with CMake's ExternalProject by default. CMake 3.7 added -# SOURCE_SUBDIR as a means of supporting this but that's too new to require -# yet. - -# Compose CMAKE_ARGS -set( - cmake_args - -DCMAKE_INSTALL_PREFIX:PATH= - -DBUILD_SHARED_LIBS:BOOL=OFF - -Dprotobuf_BUILD_TESTS:BOOL=OFF - -Dprotobuf_WITH_ZLIB:BOOL=OFF - -Dprotobuf_MSVC_STATIC_RUNTIME:BOOL=ON -) - -# For single-configuration generators, pass CONFIG at configure time -if(NOT CMAKE_CONFIGURATION_TYPES) - list(APPEND cmake_args -DCMAKE_BUILD_TYPE=$) -endif() - - -if(CMAKE_VERSION VERSION_LESS "3.7") - # Manually compose the commands required to invoke CMake in the external - # project. - # - # Compose CONFIGURE_COMMAND so as to preserve the outer CMake's generator - # configuration in the sub-build. Without this the builds can invoke - # different compilers or disagree about word size or other fundamental - # parameters making the output of the sub-build useless. This is based on - # _ep_extract_configure_command in ExternalProject.cmake. - set(configure "${CMAKE_COMMAND}") - - if(CMAKE_EXTRA_GENERATOR) - list(APPEND configure "-G${CMAKE_EXTRA_GENERATOR} - ${CMAKE_GENERATOR}") - else() - list(APPEND configure "-G${CMAKE_GENERATOR}") - endif() - - if(CMAKE_GENERATOR_PLATFORM) - list(APPEND configure "-A${CMAKE_GENERATOR_PLATFORM}") - endif() - - if(CMAKE_GENERATOR_TOOLSET) - list(APPEND configure "-T${CMAKE_GENERATOR_TOOLSET}") - endif() - - list( - APPEND configure - ${cmake_args} - "${PROJECT_BINARY_DIR}/src/protobuf/cmake" - ) - - # Compose BUILD_COMMAND and INSTALL_COMMAND - set(build "${CMAKE_COMMAND}" --build .) - - # For multi-configuration generators, pass CONFIG at build time. - if(CMAKE_CONFIGURATION_TYPES) - list(APPEND build --config $) - endif() - - set(install ${build} --target install) - - set( - commands - CONFIGURE_COMMAND ${configure} - BUILD_COMMAND ${build} - INSTALL_COMMAND ${install} - ) - -else() - # CMake 3.7 and above support this directly. - set( - commands - CMAKE_ARGS ${cmake_args} - SOURCE_SUBDIR cmake - ) -endif() +# This ExternalProject unpacks itself inside the gRPC source tree. CMake clears +# the SOURCE_DIR when unpacking so this must come after grpc despite the fact +# that grpc logically depends upon this. ExternalProject_Add( protobuf + DEPENDS + grpc-download DOWNLOAD_DIR ${FIREBASE_DOWNLOAD_DIR} DOWNLOAD_NAME protobuf-v3.5.1.1.tar.gz @@ -105,9 +33,10 @@ ExternalProject_Add( URL_HASH SHA256=56b5d9e1ab2bf4f5736c4cfba9f4981fbc6976246721e7ded5602fbaee6d6869 PREFIX ${PROJECT_BINARY_DIR} - INSTALL_DIR ${FIREBASE_INSTALL_DIR} - - ${commands} + SOURCE_DIR ${PROJECT_BINARY_DIR}/src/grpc/third_party/protobuf + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" TEST_COMMAND "" ) -- cgit v1.2.3