arm_brpc.cmake 3.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

15
include(ExternalProject)
16 17 18 19 20 21 22 23 24 25 26 27

#find_package(OpenSSL REQUIRED)

#message(STATUS "ssl:" ${OPENSSL_SSL_LIBRARY})
#message(STATUS "crypto:" ${OPENSSL_CRYPTO_LIBRARY})

#ADD_LIBRARY(ssl SHARED IMPORTED GLOBAL)
#SET_PROPERTY(TARGET ssl PROPERTY IMPORTED_LOCATION ${OPENSSL_SSL_LIBRARY})

#ADD_LIBRARY(crypto SHARED IMPORTED GLOBAL)
#SET_PROPERTY(TARGET crypto PROPERTY IMPORTED_LOCATION ${OPENSSL_CRYPTO_LIBRARY})

28 29 30 31 32 33 34 35
if((NOT DEFINED ARM_BRPC_NAME) OR (NOT DEFINED ARM_BRPC_URL))
  set(ARM_BRPC_VER
      "1.1.0"
      CACHE STRING "" FORCE)
  set(ARM_BRPC_NAME
      "arm_brpc"
      CACHE STRING "" FORCE)
endif()
36

37 38 39 40 41 42 43 44 45 46 47 48
message(STATUS "ARM_BRPC_NAME: ${ARM_BRPC_NAME}, ARM_BRPC_URL: ${ARM_BRPC_URL}")
set(ARM_BRPC_PREFIX_DIR "${THIRD_PARTY_PATH}/arm_brpc")
set(ARM_BRPC_PROJECT "extern_arm_brpc")
set(ARM_BRPC_DOWNLOAD_DIR "${ARM_BRPC_PREFIX_DIR}/src/${ARM_BRPC_PROJECT}")
set(ARM_BRPC_DST_DIR "output")
set(ARM_BRPC_INSTALL_ROOT "${THIRD_PARTY_PATH}/install")
set(ARM_BRPC_INSTALL_DIR ${ARM_BRPC_INSTALL_ROOT}/arm_brpc/output)
set(ARM_BRPC_ROOT ${ARM_BRPC_INSTALL_DIR})
set(ARM_BRPC_INC_DIR ${ARM_BRPC_ROOT}/include)
set(ARM_BRPC_LIB_DIR ${ARM_BRPC_ROOT}/lib)
set(ARM_BRPC_LIB ${ARM_BRPC_LIB_DIR}/libbrpc.a)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}" "${ARM_BRPC_ROOT}/lib")
49

50
include_directories(${ARM_BRPC_INSTALL_ROOT}/${ARM_BRPC_NAME}/output/include)
51

52 53 54
file(
  WRITE ${ARM_BRPC_DOWNLOAD_DIR}/CMakeLists.txt
  "PROJECT(ARM_BRPC)\n" "cmake_minimum_required(VERSION 3.0)\n"
55 56
  "install(DIRECTORY ${ARM_BRPC_DST_DIR} ${ARM_BRPC_DST_DIR} \n"
  "        DESTINATION ${ARM_BRPC_NAME})\n")
57 58 59 60

set(ARM_BRPC_URL
    "https://paddlerec.bj.bcebos.com/online_infer/arm_brpc_ubuntu18/output.tar.gz"
    CACHE STRING "" FORCE)
61
ExternalProject_Add(
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
  ${ARM_BRPC_PROJECT}
  ${EXTERNAL_PROJECT_LOG_ARGS}
  PREFIX ${ARM_BRPC_PREFIX_DIR}
  DOWNLOAD_DIR ${ARM_BRPC_DOWNLOAD_DIR}
  DOWNLOAD_COMMAND rm -rf output.tar.gz && wget --no-check-certificate
                   ${ARM_BRPC_URL} && tar zxvf output.tar.gz
  #DOWNLOAD_COMMAND      cp /home/wangbin44/Paddle/build/output.tar.gz .
  #                      && tar zxvf output.tar.gz
  DOWNLOAD_NO_PROGRESS 1
  UPDATE_COMMAND ""
  CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${ARM_BRPC_INSTALL_ROOT}
             -DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE}
  CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${ARM_BRPC_INSTALL_ROOT}
                   -DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE}
  BUILD_BYPRODUCTS ${ARM_BRPC_LIB})
77

78 79 80
add_library(arm_brpc STATIC IMPORTED GLOBAL) # 直接导入已经生成的库
set_property(TARGET arm_brpc PROPERTY IMPORTED_LOCATION ${ARM_BRPC_LIB})
add_dependencies(arm_brpc ${ARM_BRPC_PROJECT})