Repository: arrow Updated Branches: refs/heads/master 894f74009 -> a6a97a9d4
ARROW-1631 [C++] Add GRPC to ThirdpartyToolchain - Building of GRPC and linking to GRPC's libs is turned on by default ( building of GRPC takes too much CPU time; It makes sense to find the way to decrease build time of GRPC; Maybe, some patch to adjust their CMake builds script to not build not relevant targets like various languages support plugins ) - Searching for pre-installed GRPC package with `find_package(gRPC CONFIG REQUIRED) ` doesn't work correctly yet. Author: Max Risuhin <[email protected]> Closes #1182 from MaxRis/ARROW-1631 and squashes the following commits: 25b651bf [Max Risuhin] ARROW-1631: [C++] Add GRPC to ThirdpartyToolchain Project: http://git-wip-us.apache.org/repos/asf/arrow/repo Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/a6a97a9d Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/a6a97a9d Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/a6a97a9d Branch: refs/heads/master Commit: a6a97a9d4c07873266a71d8c87069dc4d168e4d2 Parents: 894f740 Author: Max Risuhin <[email protected]> Authored: Sat Oct 14 11:47:58 2017 -0400 Committer: Wes McKinney <[email protected]> Committed: Sat Oct 14 11:47:58 2017 -0400 ---------------------------------------------------------------------- cpp/CMakeLists.txt | 12 ++++++ cpp/cmake_modules/ThirdpartyToolchain.cmake | 51 ++++++++++++++++++++++++ 2 files changed, 63 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/arrow/blob/a6a97a9d/cpp/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 12d4854..a159b1e 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -190,6 +190,10 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") "Build with zstd compression" ON) + option(ARROW_WITH_GRPC + "Build with GRPC" + OFF) + option(ARROW_VERBOSE_THIRDPARTY_BUILD "If off, output from ExternalProjects will be logged to files rather than shown" ON) @@ -510,6 +514,14 @@ if (ARROW_WITH_ZSTD) SET(ARROW_STATIC_LINK_LIBS zstd_static ${ARROW_STATIC_LINK_LIBS}) endif() +if (ARROW_WITH_GRPC) + SET(ARROW_STATIC_LINK_LIBS + grpc_grp + grpc_grpc + grpc_grpcpp + ${ARROW_STATIC_LINK_LIBS}) +endif() + if (ARROW_STATIC_LINK_LIBS) add_dependencies(arrow_dependencies ${ARROW_STATIC_LINK_LIBS}) endif() http://git-wip-us.apache.org/repos/asf/arrow/blob/a6a97a9d/cpp/cmake_modules/ThirdpartyToolchain.cmake ---------------------------------------------------------------------- diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 98186d0..42d7edd 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -29,6 +29,7 @@ set(SNAPPY_VERSION "1.1.3") set(BROTLI_VERSION "v0.6.0") set(LZ4_VERSION "1.7.5") set(ZSTD_VERSION "1.2.0") +set(GRPC_VERSION "94582910ad7f82ad447ecc72e6548cb669e4f7a9") # v1.6.5 string(TOUPPER ${CMAKE_BUILD_TYPE} UPPERCASE_BUILD_TYPE) @@ -105,6 +106,10 @@ if (DEFINED ENV{ZSTD_HOME}) set(ZSTD_HOME "$ENV{ZSTD_HOME}") endif() +if (DEFINED ENV{GRPC_HOME}) + set(GRPC_HOME "$ENV{GRPC_HOME}") +endif() + # Ensure that a default make is set if ("${MAKE}" STREQUAL "") if (NOT MSVC) @@ -782,3 +787,49 @@ if (ARROW_WITH_ZSTD) add_dependencies(zstd_static zstd_ep) endif() endif() + +if (ARROW_WITH_GRPC) +# ---------------------------------------------------------------------- +# GRPC + if ("${GRPC_HOME}" STREQUAL "") + set(GRPC_VENDORED 1) + set(GRPC_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/grpc_ep-prefix/src/grpc_ep-build") + set(GRPC_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/grpc_ep/src/grpc_ep-install") + set(GRPC_HOME "${GRPC_PREFIX}") + set(GRPC_INCLUDE_DIR "${GRPC_PREFIX}/include") + set(GRPC_STATIC_LIBRARY_GPR "${GRPC_BUILD_DIR}/${CMAKE_CFG_INTDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}gpr${CMAKE_STATIC_LIBRARY_SUFFIX}") + set(GRPC_STATIC_LIBRARY_GRPC "${GRPC_BUILD_DIR}/${CMAKE_CFG_INTDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}grpc${CMAKE_STATIC_LIBRARY_SUFFIX}") + set(GRPC_STATIC_LIBRARY_GRPCPP "${GRPC_BUILD_DIR}/${CMAKE_CFG_INTDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}grpc++${CMAKE_STATIC_LIBRARY_SUFFIX}") + set(GRPC_CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + "-DCMAKE_CXX_FLAGS=${EP_CXX_FLAGS}" + "-DCMAKE_C_FLAGS=${EX_C_FLAGS}" + -DCMAKE_INSTALL_PREFIX=${GRPC_PREFIX} + -DBUILD_SHARED_LIBS=OFF) + + ExternalProject_Add(grpc_ep + GIT_REPOSITORY "https://github.com/grpc/grpc" + GIT_TAG ${GRPC_VERSION} + BUILD_BYPRODUCTS "${GRPC_STATIC_LIBRARY_GPR}" "${GRPC_STATIC_LIBRARY_GRPC}" "${GRPC_STATIC_LIBRARY_GRPCPP}" + ${GRPC_BUILD_BYPRODUCTS} + ${EP_LOG_OPTIONS} + CMAKE_ARGS ${GRPC_CMAKE_ARGS}) + else() + find_package(gRPC CONFIG REQUIRED) + set(GRPC_VENDORED 0) + endif() + + include_directories(SYSTEM ${GRPC_INCLUDE_DIR}) + ADD_THIRDPARTY_LIB(grpc_grp + STATIC_LIB ${GRPC_STATIC_LIBRARY_GPR}) + ADD_THIRDPARTY_LIB(grpc_grpc + STATIC_LIB ${GRPC_STATIC_LIBRARY_GRPC}) + ADD_THIRDPARTY_LIB(grpc_grpcpp + STATIC_LIB ${GRPC_STATIC_LIBRARY_GRPCPP}) + + if (GRPC_VENDORED) + add_dependencies(grpc_grp grpc_ep) + add_dependencies(grpc_grpc grpc_ep) + add_dependencies(grpc_grpcpp grpc_ep) + endif() + +endif()
