box_ps.cmake 2.6 KB
Newer Older
H
hutuxian 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14
# Copyright (c) 2019 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)
H
hutuxian 已提交
16

17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
set(BOX_PS_PROJECT "extern_box_ps")
if((NOT DEFINED BOX_PS_VER) OR (NOT DEFINED BOX_PS_URL))
  message(STATUS "use pre defined download url")
  set(BOX_PS_VER
      "0.1.1"
      CACHE STRING "" FORCE)
  set(BOX_PS_NAME
      "box_ps"
      CACHE STRING "" FORCE)
  set(BOX_PS_URL
      "http://box-ps.gz.bcebos.com/box_ps.tar.gz"
      CACHE STRING "" FORCE)
endif()
message(STATUS "BOX_PS_NAME: ${BOX_PS_NAME}, BOX_PS_URL: ${BOX_PS_URL}")
set(BOX_PS_SOURCE_DIR "${THIRD_PARTY_PATH}/box_ps")
set(BOX_PS_DOWNLOAD_DIR "${BOX_PS_SOURCE_DIR}/src/${BOX_PS_PROJECT}")
set(BOX_PS_DST_DIR "box_ps")
set(BOX_PS_INSTALL_ROOT "${THIRD_PARTY_PATH}/install")
set(BOX_PS_INSTALL_DIR ${BOX_PS_INSTALL_ROOT}/${BOX_PS_DST_DIR})
set(BOX_PS_ROOT ${BOX_PS_INSTALL_DIR})
set(BOX_PS_INC_DIR ${BOX_PS_ROOT}/include)
set(BOX_PS_LIB_DIR ${BOX_PS_ROOT}/lib)
set(BOX_PS_LIB ${BOX_PS_LIB_DIR}/libbox_ps.so)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}" "${BOX_PS_ROOT}/lib")
H
hutuxian 已提交
41

42 43 44 45
include_directories(${BOX_PS_INC_DIR})
file(
  WRITE ${BOX_PS_DOWNLOAD_DIR}/CMakeLists.txt
  "PROJECT(BOX_PS)\n" "cmake_minimum_required(VERSION 3.0)\n"
H
hutuxian 已提交
46 47 48
  "install(DIRECTORY ${BOX_PS_NAME}/include ${BOX_PS_NAME}/lib \n"
  "        DESTINATION ${BOX_PS_DST_DIR})\n")
ExternalProject_Add(
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
  ${BOX_PS_PROJECT}
  ${EXTERNAL_PROJECT_LOG_ARGS}
  PREFIX ${BOX_PS_SOURCE_DIR}
  DOWNLOAD_DIR ${BOX_PS_DOWNLOAD_DIR}
  DOWNLOAD_COMMAND wget --no-check-certificate ${BOX_PS_URL} -c -q -O
                   ${BOX_PS_NAME}.tar.gz && tar zxvf ${BOX_PS_NAME}.tar.gz
  DOWNLOAD_NO_PROGRESS 1
  UPDATE_COMMAND ""
  CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${BOX_PS_INSTALL_ROOT}
             -DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE}
  CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${BOX_PS_INSTALL_ROOT}
                   -DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE}
  BUILD_BYPRODUCTS ${BOX_PS_LIB})
add_library(box_ps SHARED IMPORTED GLOBAL)
set_property(TARGET box_ps PROPERTY IMPORTED_LOCATION ${BOX_PS_LIB})
add_dependencies(box_ps ${BOX_PS_PROJECT})