diff options
Diffstat (limited to 'cmake/external')
-rw-r--r-- | cmake/external/googletest.cmake | 9 | ||||
-rw-r--r-- | cmake/external/grpc.cmake | 29 | ||||
-rw-r--r-- | cmake/external/leveldb.cmake | 4 | ||||
-rw-r--r-- | cmake/external/nanopb.cmake | 9 | ||||
-rw-r--r-- | cmake/external/protobuf.cmake | 95 |
5 files changed, 118 insertions, 28 deletions
diff --git a/cmake/external/googletest.cmake b/cmake/external/googletest.cmake index 24da386..3af136e 100644 --- a/cmake/external/googletest.cmake +++ b/cmake/external/googletest.cmake @@ -17,17 +17,16 @@ include(ExternalProject) ExternalProject_Add( googletest - DOWNLOAD_DIR ${PROJECT_BINARY_DIR}/downloads + DOWNLOAD_DIR ${FIREBASE_DOWNLOAD_DIR} DOWNLOAD_NAME googletest-1.8.0.tar.gz URL https://github.com/google/googletest/archive/release-1.8.0.tar.gz URL_HASH SHA256=58a6f4277ca2bc8565222b3bbd58a177609e9c488e8a72649359ba51450db7d8 PREFIX ${PROJECT_BINARY_DIR}/external/googletest - # Just download the sources without building. + CMAKE_CACHE_ARGS + -DCMAKE_INSTALL_PREFIX:STRING=${FIREBASE_INSTALL_DIR} + UPDATE_COMMAND "" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" TEST_COMMAND "" ) 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} diff --git a/cmake/external/leveldb.cmake b/cmake/external/leveldb.cmake index dcbef6c..db8aa4c 100644 --- a/cmake/external/leveldb.cmake +++ b/cmake/external/leveldb.cmake @@ -44,12 +44,12 @@ else() ExternalProject_Add( leveldb - DOWNLOAD_DIR ${PROJECT_BINARY_DIR}/downloads + DOWNLOAD_DIR ${FIREBASE_DOWNLOAD_DIR} DOWNLOAD_NAME leveldb-v1.20.tar.gz URL https://github.com/google/leveldb/archive/v1.20.tar.gz URL_HASH SHA256=f5abe8b5b209c2f36560b75f32ce61412f39a2922f7045ae764a2c23335b6664 - PREFIX ${PROJECT_BINARY_DIR}/external/leveldb + PREFIX ${FIREBASE_BINARY_DIR}/external/leveldb # LevelDB's configuration is done in the Makefile CONFIGURE_COMMAND "" diff --git a/cmake/external/nanopb.cmake b/cmake/external/nanopb.cmake index 6ca47c0..39eb833 100644 --- a/cmake/external/nanopb.cmake +++ b/cmake/external/nanopb.cmake @@ -14,17 +14,14 @@ include(ExternalProject) -set( - NANOPB_PROTOC_BIN - ${FIREBASE_INSTALL_DIR}/external/protobuf/src/protobuf-build/${CMAKE_CFG_INTDIR}/protoc -) +set(NANOPB_PROTOC_BIN ${FIREBASE_INSTALL_DIR}/bin/protoc) ExternalProject_Add( nanopb DEPENDS protobuf - DOWNLOAD_DIR ${PROJECT_BINARY_DIR}/downloads + DOWNLOAD_DIR ${FIREBASE_DOWNLOAD_DIR} URL https://github.com/nanopb/nanopb/archive/nanopb-0.3.9.1.tar.gz URL_HASH SHA256=67460d0c0ad331ef4d5369ad337056d0cd2f900c94887628d287eb56c69324bc @@ -32,11 +29,11 @@ ExternalProject_Add( CMAKE_ARGS -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DCMAKE_INSTALL_PREFIX:STRING=${FIREBASE_INSTALL_DIR} -DBUILD_SHARED_LIBS:BOOL=OFF -Dnanopb_BUILD_GENERATOR:BOOL=ON -Dnanopb_PROTOC_PATH:STRING=${NANOPB_PROTOC_BIN} UPDATE_COMMAND "" TEST_COMMAND "" - INSTALL_COMMAND "" ) diff --git a/cmake/external/protobuf.cmake b/cmake/external/protobuf.cmake index acc5a96..66d1426 100644 --- a/cmake/external/protobuf.cmake +++ b/cmake/external/protobuf.cmake @@ -14,28 +14,97 @@ include(ExternalProject) +# 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=<INSTALL_DIR> + -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=$<CONFIG>) +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}/external/protobuf/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 $<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() + ExternalProject_Add( protobuf - DOWNLOAD_DIR ${PROJECT_BINARY_DIR}/downloads - DOWNLOAD_NAME protobuf-v3.5.11.tar.gz + DOWNLOAD_DIR ${FIREBASE_DOWNLOAD_DIR} + DOWNLOAD_NAME protobuf-v3.5.1.1.tar.gz URL https://github.com/google/protobuf/archive/v3.5.1.1.tar.gz URL_HASH SHA256=56b5d9e1ab2bf4f5736c4cfba9f4981fbc6976246721e7ded5602fbaee6d6869 PREFIX ${PROJECT_BINARY_DIR}/external/protobuf + INSTALL_DIR ${FIREBASE_INSTALL_DIR} - # protobuf ships CMake files but not at the root of the repo, which confuses - # CMake by default. Unfortunately when you override CONFIGURE_COMMAND like - # this, CMake no longer automatically plumbs in CMAKE_ARGS and friends so - # those need to be manually passed in this command line. - CONFIGURE_COMMAND - ${CMAKE_COMMAND} - -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} - -DCMAKE_INSTALL_PREFIX:PATH=${FIREBASE_INSTALL_DIR} - -Dprotobuf_BUILD_TESTS=OFF - ${PROJECT_BINARY_DIR}/external/protobuf/src/protobuf/cmake + ${commands} UPDATE_COMMAND "" TEST_COMMAND "" - INSTALL_COMMAND "" ) |