|
1 |
| -cmake_minimum_required(VERSION 2.8) |
| 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 | +cmake_minimum_required(VERSION 3.0) |
2 | 16 |
|
3 | 17 | project(paddle CXX C)
|
4 | 18 |
|
5 | 19 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
|
6 | 20 | set(PROJ_ROOT ${CMAKE_SOURCE_DIR})
|
7 |
| -include(package) |
8 |
| -find_package(SWIG 2.0) |
9 |
| -find_package(CUDA QUIET) |
10 |
| -find_package(Protobuf REQUIRED) |
11 | 21 |
|
12 |
| -# Check protobuf library version. |
13 |
| -execute_process(COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} --version |
14 |
| - OUTPUT_VARIABLE PROTOBUF_VERSION) |
15 |
| -string(REPLACE "libprotoc " "" PROTOBUF_VERSION ${PROTOBUF_VERSION}) |
| 22 | +find_package(Sphinx) |
| 23 | +find_package(CUDA QUIET) |
| 24 | +find_package(Git REQUIRED) |
| 25 | +find_package(Threads REQUIRED) |
16 | 26 |
|
17 |
| -set(PROTOBUF_3 OFF) |
18 |
| -if (${PROTOBUF_VERSION} VERSION_GREATER "3.0.0" OR ${PROTOBUF_VERSION} VERSION_EQUAL "3.0.0") |
19 |
| - set(PROTOBUF_3 ON) |
20 |
| -endif() |
| 27 | +include(system) |
| 28 | +include(simd) |
21 | 29 |
|
22 |
| -find_package(PythonLibs 2.7 REQUIRED) |
23 |
| -find_package(PythonInterp 2.7 REQUIRED) |
24 |
| -find_package(ZLIB REQUIRED) |
25 |
| -find_package(NumPy REQUIRED) |
26 |
| -find_package(Threads REQUIRED) |
27 |
| -find_package(AVX QUIET) |
28 |
| -find_package(Glog REQUIRED) |
29 |
| -find_package(Gflags REQUIRED) |
30 |
| -find_package(GTest) |
31 |
| -find_package(Sphinx) |
32 |
| -find_package(Doxygen) |
33 |
| -include(cblas) |
34 |
| -find_program(M4_EXECUTABLE m4) |
35 |
| -###################### Configurations ########################### |
| 30 | +###################### Configurations ############################ |
36 | 31 | option(WITH_DSO "Compile PaddlePaddle with dynamic linked libraries" ON)
|
37 | 32 | option(WITH_GPU "Compile PaddlePaddle with gpu" ${CUDA_FOUND})
|
38 | 33 | option(WITH_DOUBLE "Compile PaddlePaddle with double precision, otherwise use single precision" OFF)
|
39 | 34 | option(WITH_AVX "Compile PaddlePaddle with avx intrinsics" ${AVX_FOUND})
|
40 | 35 | option(WITH_PYTHON "Compile PaddlePaddle with python interpreter" ON)
|
41 |
| -option(WITH_STYLE_CHECK "Style Check for PaddlePaddle" ${PYTHONINTERP_FOUND}) |
| 36 | +option(WITH_STYLE_CHECK "Style Check for PaddlePaddle" ON) |
42 | 37 | option(WITH_RDMA "Compile PaddlePaddle with rdma support" OFF)
|
43 | 38 | option(WITH_TIMER "Compile PaddlePaddle use timer" OFF)
|
44 | 39 | option(WITH_PROFILER "Compile PaddlePaddle use gpu profiler" OFF)
|
45 |
| -option(WITH_TESTING "Compile and run unittest for PaddlePaddle" ${GTEST_FOUND}) |
| 40 | +option(WITH_TESTING "Compile and run unittest for PaddlePaddle" ON) |
46 | 41 | option(WITH_DOC "Compile PaddlePaddle with documentation" OFF)
|
47 |
| -option(WITH_SWIG_PY "Compile PaddlePaddle with py PaddlePaddle prediction api" ${SWIG_FOUND}) |
| 42 | +option(WITH_SWIG_PY "Compile PaddlePaddle with py PaddlePaddle prediction api" ON) |
48 | 43 | option(ON_TRAVIS "Running test on travis-ci or not." OFF)
|
49 | 44 | option(ON_COVERALLS "Generating code coverage data on coveralls or not." OFF)
|
50 | 45 | option(COVERALLS_UPLOAD "Uploading the generated coveralls json." ON)
|
51 | 46 |
|
| 47 | +include(external/zlib) # download, build, install zlib |
| 48 | +include(external/gflags) # download, build, install gflags |
| 49 | +include(external/glog) # download, build, install glog |
| 50 | +include(external/gtest) # download, build, install gtest |
| 51 | +include(external/protobuf) # download, build, install protobuf |
| 52 | +include(external/python) # download, build, install python |
| 53 | +include(external/openblas) # download, build, install openblas |
| 54 | +include(external/swig) # download, build, install swig |
| 55 | +include(external/warpctc) # download, build, install warpctc |
| 56 | + |
| 57 | +include(package) # set paddle packages |
| 58 | +include(cpplint) # set paddle c++ style |
| 59 | +include(ccache) # set ccache for compilation |
| 60 | +include(util) # set unittest and link libs |
| 61 | +include(rdma) # set rdma libraries |
| 62 | +include(flags) # set paddle compile flags |
| 63 | +include(cudnn) # set cudnn libraries |
| 64 | +include(version) # set PADDLE_VERSION |
| 65 | +include(coveralls) # set code coverage |
| 66 | +include(python_module) # set python module |
| 67 | + |
| 68 | +include(configure) # add paddle env configuration |
52 | 69 |
|
53 |
| -include(cpplint) |
54 |
| -include(ccache) |
55 |
| -if(WITH_RDMA) |
56 |
| - include(rdma) |
57 |
| -endif() |
58 |
| -include(util) |
59 |
| -include(flags) |
60 |
| -include(cudnn) |
61 |
| -include(FindPythonModule) |
62 |
| -include(check_packages) |
63 |
| -include(swig) |
64 |
| -include(coveralls) |
65 |
| - |
66 |
| -# Set PaddlePaddle version to Git tag name or Git commit ID. |
67 |
| -find_package(Git REQUIRED) |
68 |
| -# version.cmake will get the current PADDLE_VERSION |
69 |
| -include(version) |
70 |
| -add_definitions(-DPADDLE_VERSION=${PADDLE_VERSION}) |
71 |
| - |
72 |
| -if(NOT WITH_GPU) |
73 |
| - add_definitions(-DPADDLE_ONLY_CPU) |
74 |
| - add_definitions(-DHPPL_STUB_FUNC) |
75 |
| - |
76 |
| - list(APPEND CMAKE_CXX_SOURCE_FILE_EXTENSIONS cu) |
77 |
| -else() |
78 |
| - if(${CUDA_VERSION_MAJOR} VERSION_LESS 7) |
79 |
| - message(FATAL_ERROR "Paddle need CUDA >= 7.0 to compile") |
80 |
| - endif() |
81 |
| - |
82 |
| - if(NOT CUDNN_FOUND) |
83 |
| - message(FATAL_ERROR "Paddle need cudnn to compile") |
84 |
| - endif() |
85 |
| - |
86 |
| - if(WITH_AVX) |
87 |
| - set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler ${AVX_FLAG}") |
88 |
| - else(WITH_AVX) |
89 |
| - set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler ${SSE3_FLAG}") |
90 |
| - endif(WITH_AVX) |
91 |
| - |
92 |
| - # Include cuda and cudnn |
93 |
| - include_directories(${CUDNN_INCLUDE_DIR}) |
94 |
| - include_directories(${CUDA_TOOLKIT_INCLUDE}) |
95 |
| -endif(NOT WITH_GPU) |
96 |
| - |
97 |
| -if(WITH_DSO) |
98 |
| - add_definitions(-DPADDLE_USE_DSO) |
99 |
| -endif(WITH_DSO) |
100 |
| - |
101 |
| -if(WITH_DOUBLE) |
102 |
| - add_definitions(-DPADDLE_TYPE_DOUBLE) |
103 |
| - set(ACCURACY double) |
104 |
| -else(WITH_DOUBLE) |
105 |
| - set(ACCURACY float) |
106 |
| -endif(WITH_DOUBLE) |
107 |
| - |
108 |
| -if(NOT WITH_TIMER) |
109 |
| - add_definitions(-DPADDLE_DISABLE_TIMER) |
110 |
| -endif(NOT WITH_TIMER) |
111 |
| - |
112 |
| -if(NOT WITH_PROFILER) |
113 |
| - add_definitions(-DPADDLE_DISABLE_PROFILER) |
114 |
| -endif(NOT WITH_PROFILER) |
115 |
| - |
116 |
| -if(WITH_AVX) |
117 |
| - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${AVX_FLAG}") |
118 |
| - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${AVX_FLAG}") |
119 |
| -else(WITH_AVX) |
120 |
| - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SSE3_FLAG}") |
121 |
| - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SSE3_FLAG}") |
122 |
| -endif(WITH_AVX) |
123 |
| - |
124 |
| -if(WITH_PYTHON) |
125 |
| - include_directories(${PYTHON_INCLUDE_DIR}) |
126 |
| - include_directories(${PYTHON_NUMPY_INCLUDE_DIR}) |
127 |
| -else(WITH_PYTHON) |
128 |
| - add_definitions(-DPADDLE_NO_PYTHON) |
129 |
| -endif(WITH_PYTHON) |
130 |
| - |
131 |
| -if(WITH_RDMA) |
132 |
| - include_directories("${RDMA_INC_DIR}") |
133 |
| -else(WITH_RDMA) |
134 |
| - add_definitions(-DPADDLE_DISABLE_RDMA) |
135 |
| -endif(WITH_RDMA) |
136 |
| - |
137 |
| -# glog |
138 |
| -include_directories(${LIBGLOG_INCLUDE_DIR}) |
139 |
| - |
140 |
| -#gflags |
141 |
| -add_definitions(-DGFLAGS_NS=${GFLAGS_NAMESPACE}) |
142 |
| -include_directories(${GFLAGS_INCLUDE_DIRS}) |
143 |
| - |
144 |
| -if(WITH_TESTING) |
145 |
| - enable_testing() |
146 |
| - include_directories(${GTEST_INCLUDE_DIRS}) |
147 |
| -endif() |
148 |
| - |
149 |
| -include_directories("${CBLAS_INC_DIR}") |
150 | 70 | include_directories("${PROJ_ROOT}")
|
151 | 71 | include_directories("${PROJ_ROOT}/paddle/cuda/include")
|
152 |
| -include_directories(${PROTOBUF_INCLUDE_DIRS}) |
153 | 72 | include_directories("${CMAKE_CURRENT_BINARY_DIR}/proto")
|
154 |
| -if(EXISTS "${PROJ_ROOT}/paddle/internals/CMakeLists.txt") |
155 |
| - set(PADDLE_WITH_INTERNAL ON) |
156 |
| - include(paddle/internals/CMakeLists.txt) |
157 |
| -else() |
158 |
| - set(PADDLE_WITH_INTERNAL OFF) |
159 |
| - set(INTERNAL_PROTO_PATH "") |
160 |
| -endif() |
| 73 | + |
| 74 | +set(EXTERNAL_LIBS |
| 75 | + # have not include gtest here. |
| 76 | + ${GFLAGS_LIBRARIES} |
| 77 | + ${GLOG_LIBRARIES} |
| 78 | + ${CBLAS_LIBRARIES} |
| 79 | + ${PROTOBUF_LIBRARY} |
| 80 | + ${ZLIB_LIBRARIES} |
| 81 | +) |
| 82 | + |
161 | 83 | add_subdirectory(proto)
|
162 | 84 | add_subdirectory(paddle)
|
163 | 85 | add_subdirectory(python)
|
| 86 | + |
164 | 87 | if(WITH_DOC)
|
165 | 88 | add_subdirectory(doc)
|
166 | 89 | endif()
|
0 commit comments