boost.cmake 2.8 KB
Newer Older
1
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved.
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)
16 17

set(BOOST_PROJECT       "extern_boost")
18 19 20 21 22 23 24
# To release PaddlePaddle as a pip package, we have to follow the
# manylinux1 standard, which features as old Linux kernels and
# compilers as possible and recommends CentOS 5. Indeed, the earliest
# CentOS version that works with NVIDIA CUDA is CentOS 6.  And a new
# version of boost, say, 1.66.0, doesn't build on CentOS 6.  We
# checked that the devtools package of CentOS 6 installs boost 1.41.0.
# So we use 1.41.0 here.
Y
yi.wu 已提交
25
set(BOOST_VER           "1.41.0")
26 27 28
if((NOT DEFINED BOOST_TAR) OR (NOT DEFINED BOOST_URL))
    message(STATUS "use pre defined download url")
    set(BOOST_TAR "boost_1_41_0" CACHE STRING "" FORCE)
29
    set(BOOST_URL "http://paddlepaddledeps.cdn.bcebos.com/${BOOST_TAR}.tar.gz" CACHE STRING "" FORCE)
30
endif()
D
dzhwinter 已提交
31 32 33 34 35 36
IF (WIN32)
    MESSAGE(WARNING, "In windows, boost can not be downloaded automaticlly, please build it manually and put it at " ${THIRD_PARTY_PATH}install/boost)
else()
    MESSAGE(STATUS "BOOST_TAR: ${BOOST_TAR}, BOOST_URL: ${BOOST_URL}")
ENDIF(WIN32)

37 38
set(BOOST_SOURCES_DIR ${THIRD_PARTY_PATH}/boost)
set(BOOST_DOWNLOAD_DIR  "${BOOST_SOURCES_DIR}/src/${BOOST_PROJECT}")
39
set(BOOST_INCLUDE_DIR "${BOOST_DOWNLOAD_DIR}/${BOOST_TAR}" CACHE PATH "boost include directory." FORCE)
40
set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM 1)
41

42
include_directories(${BOOST_INCLUDE_DIR})
43

D
dzhwinter 已提交
44
if (NOT WIN32)
45 46 47 48 49
ExternalProject_Add(
    ${BOOST_PROJECT}
    ${EXTERNAL_PROJECT_LOG_ARGS}
    DOWNLOAD_DIR          ${BOOST_DOWNLOAD_DIR}
    DOWNLOAD_COMMAND      wget --no-check-certificate ${BOOST_URL} -c -q -O ${BOOST_TAR}.tar.gz
D
dzhwinter 已提交
50
    && tar zxf ${BOOST_TAR}.tar.gz
D
dzhwinter 已提交
51
DOWNLOAD_NO_PROGRESS  1
52
    PREFIX                ${BOOST_SOURCES_DIR}
53 54
    CONFIGURE_COMMAND     ""
    BUILD_COMMAND         ""
55 56 57
    INSTALL_COMMAND       ""
    UPDATE_COMMAND        ""
)
D
dzhwinter 已提交
58
endif(NOT WIN32)
59

D
dzhwinter 已提交
60
if (${CMAKE_VERSION} VERSION_LESS "3.3.0" OR NOT WIN32)
61 62 63 64 65 66 67
    set(dummyfile ${CMAKE_CURRENT_BINARY_DIR}/boost_dummy.c)
    file(WRITE ${dummyfile} "const char *dummy = \"${dummyfile}\";")
    add_library(boost STATIC ${dummyfile})
else()
    add_library(boost INTERFACE)
endif()

68 69 70
add_dependencies(boost ${BOOST_PROJECT})
list(APPEND external_project_dependencies boost)
set(Boost_INCLUDE_DIR ${BOOST_INCLUDE_DIR})