1212# See the License for the specific language governing permissions and
1313# limitations under the License
1414
15- cmake_minimum_required (VERSION 3.0)
16-
17- project (paddle CXX C)
18-
1915set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR} /cmake" )
2016set (PROJ_ROOT ${CMAKE_SOURCE_DIR} )
2117
18+ include (system )
19+
20+ if (ANDROID)
21+ cmake_minimum_required (VERSION 3.7)
22+ else ()
23+ cmake_minimum_required (VERSION 3.0)
24+ endif ()
25+
26+ project (paddle CXX C)
27+
2228find_package (Sphinx)
23- find_package (CUDA QUIET )
29+ if (NOT CMAKE_CROSSCOMPILING )
30+ find_package (CUDA QUIET )
31+ endif (NOT CMAKE_CROSSCOMPILING )
2432find_package (Git REQUIRED)
2533find_package (Threads REQUIRED)
2634
27- include (system )
2835include (simd)
2936
30- ###################### Configurations ############################
31- option (WITH_DSO "Compile PaddlePaddle with dynamic linked libraries" ON )
32- option (WITH_GPU "Compile PaddlePaddle with gpu" ${CUDA_FOUND} )
33- option (WITH_DOUBLE "Compile PaddlePaddle with double precision, otherwise use single precision" OFF )
34- option (WITH_AVX "Compile PaddlePaddle with avx intrinsics" ${AVX_FOUND} )
35- option (WITH_PYTHON "Compile PaddlePaddle with python interpreter" ON )
36- option (WITH_STYLE_CHECK "Style Check for PaddlePaddle" ON )
37- option (WITH_RDMA "Compile PaddlePaddle with rdma support" OFF )
38- option (WITH_TIMER "Compile PaddlePaddle use timer" OFF )
39- option (WITH_PROFILER "Compile PaddlePaddle use gpu profiler" OFF )
40- option (WITH_TESTING "Compile and run unittest for PaddlePaddle" ON )
41- option (WITH_DOC "Compile PaddlePaddle with documentation" OFF )
42- option (WITH_SWIG_PY "Compile PaddlePaddle with py PaddlePaddle prediction api" ON )
43- option (ON_TRAVIS "Running test on travis-ci or not." OFF )
44- option (ON_COVERALLS "Generating code coverage data on coveralls or not." OFF )
45- option (COVERALLS_UPLOAD "Uploading the generated coveralls json." ON )
37+ ################################ Configurations #######################################
38+ option (WITH_GPU "Compile PaddlePaddle with NVIDIA GPU" ${CUDA_FOUND} )
39+ option (WITH_AVX "Compile PaddlePaddle with AVX intrinsics" ${AVX_FOUND} )
40+ option (WITH_DSO "Compile PaddlePaddle with dynamic linked CUDA" ON )
41+ option (WITH_TESTING "Compile PaddlePaddle with unit testing" ON )
42+ option (WITH_SWIG_PY "Compile PaddlePaddle with inference api" ON )
43+ option (WITH_STYLE_CHECK "Compile PaddlePaddle with style check" ON )
44+ option (WITH_PYTHON "Compile PaddlePaddle with python interpreter" ON )
45+ option (WITH_DOUBLE "Compile PaddlePaddle with double precision" OFF )
46+ option (WITH_RDMA "Compile PaddlePaddle with RDMA support" OFF )
47+ option (WITH_TIMER "Compile PaddlePaddle with stats timer" OFF )
48+ option (WITH_PROFILER "Compile PaddlePaddle with GPU profiler" OFF )
49+ option (WITH_DOC "Compile PaddlePaddle with documentation" OFF )
50+ option (WITH_COVERAGE "Compile PaddlePaddle with code coverage" OFF )
51+ option (COVERALLS_UPLOAD "Package code coverage data to coveralls" OFF )
52+ option (ON_TRAVIS "Exclude special unit test on Travis CI" OFF )
53+
54+ # CMAKE_BUILD_TYPE
55+ if (NOT CMAKE_BUILD_TYPE )
56+ set (CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
57+ "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel"
58+ FORCE)
59+ endif ()
60+
61+ if (ANDROID)
62+ if (${CMAKE_SYSTEM_VERSION} VERSION_LESS "21" )
63+ message (FATAL_ERROR "Unsupport standalone toolchains with Android API level lower than 21" )
64+ endif ()
65+
66+ set (WITH_GPU OFF CACHE STRING
67+ "Disable GPU when cross-compiling for Android" FORCE)
68+ set (WITH_AVX OFF CACHE STRING
69+ "Disable AVX when cross-compiling for Android" FORCE)
70+ set (WITH_PYTHON OFF CACHE STRING
71+ "Disable PYTHON when cross-compiling for Android" FORCE)
72+ set (WITH_RDMA OFF CACHE STRING
73+ "Disable RDMA when cross-compiling for Android" FORCE)
74+ endif (ANDROID)
75+
76+ set (THIRD_PARTY_PATH "${PROJ_ROOT} /third_party" CACHE STRING
77+ "A path setting third party libraries download & build directories." )
78+ ########################################################################################
4679
4780include (external/zlib) # download, build, install zlib
4881include (external/gflags) # download, build, install gflags
@@ -53,6 +86,7 @@ include(external/python) # download, build, install python
5386include (external/openblas) # download, build, install openblas
5487include (external/swig) # download, build, install swig
5588include (external/warpctc) # download, build, install warpctc
89+ include (external/any) # download libn::any
5690
5791include (package) # set paddle packages
5892include (cpplint) # set paddle c++ style
@@ -63,23 +97,28 @@ include(flags) # set paddle compile flags
6397include (cudnn) # set cudnn libraries
6498include (version ) # set PADDLE_VERSION
6599include (coveralls) # set code coverage
66- include (python_module) # set python module
67-
68100include (configure) # add paddle env configuration
69101
70102include_directories ("${PROJ_ROOT} " )
71103include_directories ("${PROJ_ROOT} /paddle/cuda/include" )
72104include_directories ("${CMAKE_CURRENT_BINARY_DIR} /proto" )
73105
74106set (EXTERNAL_LIBS
75- # have not include gtest here.
76107 ${GFLAGS_LIBRARIES}
77108 ${GLOG_LIBRARIES}
78109 ${CBLAS_LIBRARIES}
79110 ${PROTOBUF_LIBRARY}
80111 ${ZLIB_LIBRARIES}
112+ ${PYTHON_LIBRARIES}
81113)
82114
115+ if (WITH_GPU)
116+ list (APPEND EXTERNAL_LIB ${CUDA_LIBRARIES} ${CUDA_rt_LIBRARY} )
117+ if (NOT WITH_DSO)
118+ list (APPEND EXTERNAL_LIB ${CUDNN_LIBRARY} ${CUDA_CUBLAS_LIBRARIES} ${CUDA_curand_LIBRARY} )
119+ endif (NOT WITH_DSO)
120+ endif (WITH_GPU)
121+
83122add_subdirectory (proto)
84123add_subdirectory (paddle)
85124add_subdirectory (python)
0 commit comments