Skip to content

Commit 114d0c1

Browse files
authored
Merge pull request #7707 from qingqing01/boost_cmake
Use ExternalProject_Add to download and install boost.
2 parents 95853fc + a2b560d commit 114d0c1

File tree

8 files changed

+59
-11
lines changed

8 files changed

+59
-11
lines changed

CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ if(NOT CMAKE_CROSSCOMPILING)
3131
endif(NOT CMAKE_CROSSCOMPILING)
3232
find_package(Git REQUIRED)
3333
find_package(Threads REQUIRED)
34-
if(NOT ANDROID AND NOT IOS)
35-
find_package(Boost QUIET)
36-
endif()
3734

3835
include(simd)
3936

@@ -140,6 +137,7 @@ include(external/openblas) # download, build, install openblas
140137
include(external/mkldnn) # download, build, install mkldnn
141138
include(external/swig) # download, build, install swig
142139
include(external/warpctc) # download, build, install warpctc
140+
include(external/boost) # download, build, install boost
143141
include(external/any) # download libn::any
144142
include(external/eigen) # download eigen3
145143
include(external/pybind11) # download pybind11
@@ -164,7 +162,6 @@ include_directories("${PADDLE_SOURCE_DIR}")
164162
include_directories("${PADDLE_SOURCE_DIR}/paddle/cuda/include")
165163
include_directories("${CMAKE_CURRENT_BINARY_DIR}/proto")
166164
include_directories("${CMAKE_CURRENT_BINARY_DIR}/go/pserver/client/c")
167-
include_directories(${Boost_INCLUDE_DIRS})
168165

169166
set(EXTERNAL_LIBS
170167
${GFLAGS_LIBRARIES}

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ RUN apt-get update && \
2727
curl sed grep graphviz libjpeg-dev zlib1g-dev \
2828
python-matplotlib gcc-4.8 g++-4.8 \
2929
automake locales clang-format swig doxygen cmake \
30-
liblapack-dev liblapacke-dev libboost-dev \
30+
liblapack-dev liblapacke-dev \
3131
clang-3.8 llvm-3.8 libclang-3.8-dev \
3232
net-tools libtool && \
3333
apt-get clean -y

cmake/external/boost.cmake

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
include(ExternalProject)
16+
17+
set(BOOST_PROJECT "extern_boost")
18+
set(BOOST_VER "1.66.0")
19+
set(BOOST_TAR "boost_1_66_0")
20+
set(BOOST_URL "https://dl.bintray.com/boostorg/release/${BOOST_VER}/source/${BOOST_TAR}.tar.gz")
21+
set(BOOST_SOURCES_DIR ${THIRD_PARTY_PATH}/boost)
22+
set(BOOST_DOWNLOAD_DIR "${BOOST_SOURCES_DIR}/src/${BOOST_PROJECT}")
23+
set(BOOST_INCLUDE_DIR "${BOOST_DOWNLOAD_DIR}/${BOOST_TAR}" CACHE PATH "boost include directory." FORCE)
24+
25+
include_directories(${BOOST_INCLUDE_DIR})
26+
27+
ExternalProject_Add(
28+
${BOOST_PROJECT}
29+
${EXTERNAL_PROJECT_LOG_ARGS}
30+
DOWNLOAD_DIR ${BOOST_DOWNLOAD_DIR}
31+
DOWNLOAD_COMMAND wget --no-check-certificate ${BOOST_URL} -c -q -O ${BOOST_TAR}.tar.gz
32+
&& tar zxf ${BOOST_TAR}.tar.gz
33+
DOWNLOAD_NO_PROGRESS 1
34+
PREFIX ${BOOST_SOURCES_DIR}
35+
CONFIGURE_COMMAND ""
36+
BUILD_COMMAND ""
37+
INSTALL_COMMAND ""
38+
UPDATE_COMMAND ""
39+
)
40+
41+
if (${CMAKE_VERSION} VERSION_LESS "3.3.0")
42+
set(dummyfile ${CMAKE_CURRENT_BINARY_DIR}/boost_dummy.c)
43+
file(WRITE ${dummyfile} "const char *dummy = \"${dummyfile}\";")
44+
add_library(boost STATIC ${dummyfile})
45+
else()
46+
add_library(boost INTERFACE)
47+
endif()
48+
49+
add_dependencies(boost ${BOOST_PROJECT})
50+
list(APPEND external_project_dependencies boost)
51+
set(Boost_INCLUDE_DIR ${BOOST_INCLUDE_DIR})

paddle/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ else()
1818
add_subdirectory(capi)
1919
endif()
2020

21-
if(Boost_FOUND)
21+
if(NOT ANDROID AND NOT IOS)
2222
add_subdirectory(memory)
2323
add_subdirectory(platform)
2424
add_subdirectory(framework)

paddle/framework/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# ddim lib
22
proto_library(framework_proto SRCS framework.proto)
33

4-
cc_library(ddim SRCS ddim.cc DEPS eigen3)
4+
cc_library(ddim SRCS ddim.cc DEPS eigen3 boost)
55
cc_test(ddim_test SRCS ddim_test.cc DEPS ddim)
66
nv_test(dim_test SRCS dim_test.cu DEPS ddim)
77

@@ -45,7 +45,7 @@ cc_test(data_layout_transform_test SRCS data_layout_transform_test.cc DEPS data_
4545
cc_library(data_transform SRCS data_transform.cc DEPS math_function tensor
4646
framework_proto selected_rows data_device_transform data_type_transform data_layout_transform)
4747

48-
cc_library(attribute SRCS attribute.cc DEPS framework_proto)
48+
cc_library(attribute SRCS attribute.cc DEPS framework_proto boost)
4949
cc_test(program_desc_test SRCS program_desc_test.cc DEPS proto_desc
5050
device_context)
5151
cc_library(op_proto_maker SRCS op_proto_maker.cc DEPS framework_proto attribute)

paddle/memory/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
add_subdirectory(detail)
22

33
cc_library(memory SRCS memory.cc DEPS place enforce)
4-
cc_library(memcpy SRCS memcpy.cc)
4+
cc_library(memcpy SRCS memcpy.cc DEPS place)
55

66
cc_library(paddle_memory
77
DEPS

paddle/platform/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ cc_test(cpu_info_test SRCS cpu_info_test.cc DEPS cpu_info)
1010

1111
nv_library(gpu_info SRCS gpu_info.cc DEPS gflags glog enforce)
1212

13-
cc_library(place SRCS place.cc DEPS enforce)
13+
cc_library(place SRCS place.cc DEPS enforce boost)
1414
cc_test(place_test SRCS place_test.cc DEPS place glog gflags)
1515

1616
add_subdirectory(dynload)

tools/manylinux1/Dockerfile.x64

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ RUN cd /opt && wget -q --no-check-certificate https://github.com/google/protobuf
3535
cd protobuf-3.1.0 && ./configure && make -j4 && make install && cd .. && rm -f protobuf-cpp-3.1.0.tar.gz
3636

3737

38-
RUN yum install -y sqlite-devel zlib-devel openssl-devel boost boost-devel pcre-devel vim tk-devel tkinter libtool
38+
RUN yum install -y sqlite-devel zlib-devel openssl-devel pcre-devel vim tk-devel tkinter libtool
3939

4040
RUN wget -O /root/requirements.txt https://raw.githubusercontent.com/PaddlePaddle/Paddle/develop/python/requirements.txt
4141

0 commit comments

Comments
 (0)