From 36a5ff506f02b1b40ff90a7969b683e38969499d Mon Sep 17 00:00:00 2001 From: huangjiyi <43315610+huangjiyi@users.noreply.github.com> Date: Mon, 19 Jun 2023 13:35:30 +0800 Subject: [PATCH] [cmake] add brpc third party cache (#54522) * update * test * Update brpc.cmake * update --------- Co-authored-by: risemeup1 <62429225+risemeup1@users.noreply.github.com> --- cmake/external/brpc.cmake | 25 ++++++++++++++++++++++--- cmake/external/libmct.cmake | 4 +--- cmake/external/xbyak.cmake | 4 +--- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/cmake/external/brpc.cmake b/cmake/external/brpc.cmake index f806b302529..3c44168921a 100755 --- a/cmake/external/brpc.cmake +++ b/cmake/external/brpc.cmake @@ -18,7 +18,6 @@ find_package(OpenSSL REQUIRED) message(STATUS "ssl:" ${OPENSSL_SSL_LIBRARY}) message(STATUS "crypto:" ${OPENSSL_CRYPTO_LIBRARY}) -message(STATUS "WITH_SNAPPY:" ${WITH_SNAPPRY}) add_library(ssl SHARED IMPORTED GLOBAL) set_property(TARGET ssl PROPERTY IMPORTED_LOCATION ${OPENSSL_SSL_LIBRARY}) @@ -37,6 +36,27 @@ set(BRPC_LIBRARIES include_directories(${BRPC_INCLUDE_DIR}) +# clone brpc to Paddle/third_party +set(BRPC_SOURCE_DIR ${PADDLE_SOURCE_DIR}/third_party/brpc) +set(BRPC_URL https://github.com/apache/brpc.git) +set(BRPC_TAG 1.4.0) + +if(NOT EXISTS ${BRPC_SOURCE_DIR}) + execute_process(COMMAND ${GIT_EXECUTABLE} clone -b ${BRPC_TAG} ${BRPC_URL} + ${BRPC_SOURCE_DIR}) +else() + # check git tag + execute_process( + COMMAND ${GIT_EXECUTABLE} -C ${BRPC_SOURCE_DIR} describe --tags + OUTPUT_VARIABLE CURRENT_TAG + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT ${CURRENT_TAG} STREQUAL ${BRPC_TAG}) + message(STATUS "Checkout brpc to ${BRPC_TAG}") + execute_process(COMMAND ${GIT_EXECUTABLE} -C ${BRPC_SOURCE_DIR} checkout -q + ${BRPC_TAG}) + endif() +endif() + # Reference https://stackoverflow.com/questions/45414507/pass-a-list-of-prefix-paths-to-externalproject-add-in-cmake-args set(prefix_path "${THIRD_PARTY_PATH}/install/gflags|${THIRD_PARTY_PATH}/install/leveldb|${THIRD_PARTY_PATH}/install/snappy|${THIRD_PARTY_PATH}/install/gtest|${THIRD_PARTY_PATH}/install/protobuf|${THIRD_PARTY_PATH}/install/zlib|${THIRD_PARTY_PATH}/install/glog" @@ -46,8 +66,7 @@ set(prefix_path ExternalProject_Add( extern_brpc ${EXTERNAL_PROJECT_LOG_ARGS} - GIT_REPOSITORY "https://github.com/apache/incubator-brpc" - GIT_TAG 1.4.0 + SOURCE_DIR ${BRPC_SOURCE_DIR} PREFIX ${BRPC_PREFIX_DIR} UPDATE_COMMAND "" CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} diff --git a/cmake/external/libmct.cmake b/cmake/external/libmct.cmake index 15ee5964209..44207750f71 100644 --- a/cmake/external/libmct.cmake +++ b/cmake/external/libmct.cmake @@ -65,9 +65,7 @@ ExternalProject_Add( COMMAND ${CMAKE_COMMAND} -E copy ${LIBMCT_DOWNLOAD_DIR}/CMakeLists.txt ${LIBMCT_INSTALL_DIR} CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBMCT_INSTALL_ROOT} - -DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE} - CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${LIBMCT_INSTALL_ROOT} - -DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE}) + CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${LIBMCT_INSTALL_ROOT}) add_library(libmct INTERFACE) diff --git a/cmake/external/xbyak.cmake b/cmake/external/xbyak.cmake index a146d53d606..a384c36be40 100644 --- a/cmake/external/xbyak.cmake +++ b/cmake/external/xbyak.cmake @@ -39,9 +39,7 @@ ExternalProject_Add( PREFIX ${XBYAK_PREFIX_DIR} UPDATE_COMMAND "" CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${XBYAK_INSTALL_ROOT} - -DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE} - CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${XBYAK_INSTALL_ROOT} - -DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE}) + CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${XBYAK_INSTALL_ROOT}) add_library(xbyak INTERFACE) -- GitLab