pslib.cmake 2.6 KB
Newer Older
1
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
H
pslib  
heqiaozhi 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14
#
# 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
pslib  
heqiaozhi 已提交
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 41 42
set(PSLIB_PROJECT "extern_pslib")
if((NOT DEFINED PSLIB_VER) OR (NOT DEFINED PSLIB_URL))
  message(STATUS "use pre defined download url")
  set(PSLIB_VER
      "0.1.1"
      CACHE STRING "" FORCE)
  set(PSLIB_NAME
      "pslib"
      CACHE STRING "" FORCE)
  set(PSLIB_URL
      "https://pslib.bj.bcebos.com/pslib.tar.gz"
      CACHE STRING "" FORCE)
endif()
message(STATUS "PSLIB_NAME: ${PSLIB_NAME}, PSLIB_URL: ${PSLIB_URL}")
set(PSLIB_PREFIX_DIR "${THIRD_PARTY_PATH}/pslib")
set(PSLIB_DOWNLOAD_DIR "${PSLIB_PREFIX_DIR}/src/${PSLIB_PROJECT}")
set(PSLIB_DST_DIR "pslib")
set(PSLIB_INSTALL_ROOT "${THIRD_PARTY_PATH}/install")
set(PSLIB_INSTALL_DIR ${PSLIB_INSTALL_ROOT}/${PSLIB_DST_DIR})
set(PSLIB_ROOT ${PSLIB_INSTALL_DIR})
set(PSLIB_INC_DIR ${PSLIB_ROOT}/include)
set(PSLIB_LIB_DIR ${PSLIB_ROOT}/lib)
set(PSLIB_LIB ${PSLIB_LIB_DIR}/libps.so)
set(PSLIB_VERSION_PY ${PSLIB_DOWNLOAD_DIR}/pslib/version.py)
set(PSLIB_IOMP_LIB ${PSLIB_LIB_DIR}/libiomp5.so) #todo what is this
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}" "${PSLIB_ROOT}/lib")
H
pslib  
heqiaozhi 已提交
43

44
include_directories(${PSLIB_INC_DIR})
H
pslib  
heqiaozhi 已提交
45

46 47 48
file(
  WRITE ${PSLIB_DOWNLOAD_DIR}/CMakeLists.txt
  "PROJECT(PSLIB)\n" "cmake_minimum_required(VERSION 3.0)\n"
49
  "install(DIRECTORY ${PSLIB_NAME}/include ${PSLIB_NAME}/lib \n"
H
pslib  
heqiaozhi 已提交
50 51 52
  "        DESTINATION ${PSLIB_DST_DIR})\n")

ExternalProject_Add(
53 54 55 56 57 58 59 60 61 62 63 64 65
  ${PSLIB_PROJECT}
  ${EXTERNAL_PROJECT_LOG_ARGS}
  PREFIX ${PSLIB_PREFIX_DIR}
  DOWNLOAD_DIR ${PSLIB_DOWNLOAD_DIR}
  DOWNLOAD_COMMAND wget --no-check-certificate ${PSLIB_URL} -c -q -O
                   ${PSLIB_NAME}.tar.gz && tar zxvf ${PSLIB_NAME}.tar.gz
  DOWNLOAD_NO_PROGRESS 1
  UPDATE_COMMAND ""
  CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PSLIB_INSTALL_ROOT}
             -DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE}
  CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${PSLIB_INSTALL_ROOT}
                   -DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE}
  BUILD_BYPRODUCTS ${PSLIB_LIB})
H
pslib  
heqiaozhi 已提交
66

67 68 69
add_library(pslib SHARED IMPORTED GLOBAL)
set_property(TARGET pslib PROPERTY IMPORTED_LOCATION ${PSLIB_LIB})
add_dependencies(pslib ${PSLIB_PROJECT})