12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License
14
14
15
- cmake_minimum_required (VERSION 3.0)
16
-
17
15
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR} /cmake" )
18
16
set (PROJ_ROOT ${CMAKE_SOURCE_DIR} )
19
17
20
18
include (system )
21
19
20
+ if (ANDROID)
21
+ cmake_minimum_required (VERSION 3.7)
22
+ else ()
23
+ cmake_minimum_required (VERSION 3.0)
24
+ endif ()
25
+
22
26
project (paddle CXX C)
23
27
24
28
find_package (Sphinx)
25
- find_package (CUDA QUIET )
29
+ if (NOT CMAKE_CROSSCOMPILING )
30
+ find_package (CUDA QUIET )
31
+ endif (NOT CMAKE_CROSSCOMPILING )
26
32
find_package (Git REQUIRED)
27
33
find_package (Threads REQUIRED)
28
34
@@ -41,7 +47,7 @@ option(WITH_RDMA "Compile PaddlePaddle with RDMA support" OFF)
41
47
option (WITH_TIMER "Compile PaddlePaddle with stats timer" OFF )
42
48
option (WITH_PROFILER "Compile PaddlePaddle with GPU profiler" OFF )
43
49
option (WITH_DOC "Compile PaddlePaddle with documentation" OFF )
44
- option (ON_COVERALLS "Compile PaddlePaddle with code coverage" OFF )
50
+ option (WITH_COVERAGE "Compile PaddlePaddle with code coverage" OFF )
45
51
option (COVERALLS_UPLOAD "Package code coverage data to coveralls" OFF )
46
52
option (ON_TRAVIS "Exclude special unit test on Travis CI" OFF )
47
53
@@ -52,6 +58,21 @@ if(NOT CMAKE_BUILD_TYPE)
52
58
FORCE)
53
59
endif ()
54
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
+
55
76
set (THIRD_PARTY_PATH "${PROJ_ROOT} /third_party" CACHE STRING
56
77
"A path setting third party libraries download & build directories." )
57
78
########################################################################################
@@ -65,6 +86,7 @@ include(external/python) # download, build, install python
65
86
include (external/openblas) # download, build, install openblas
66
87
include (external/swig) # download, build, install swig
67
88
include (external/warpctc) # download, build, install warpctc
89
+ include (external/any) # download libn::any
68
90
69
91
include (package) # set paddle packages
70
92
include (cpplint) # set paddle c++ style
@@ -75,22 +97,28 @@ include(flags) # set paddle compile flags
75
97
include (cudnn) # set cudnn libraries
76
98
include (version ) # set PADDLE_VERSION
77
99
include (coveralls) # set code coverage
78
-
79
100
include (configure) # add paddle env configuration
80
101
81
102
include_directories ("${PROJ_ROOT} " )
82
103
include_directories ("${PROJ_ROOT} /paddle/cuda/include" )
83
104
include_directories ("${CMAKE_CURRENT_BINARY_DIR} /proto" )
84
105
85
106
set (EXTERNAL_LIBS
86
- # have not include gtest here.
87
107
${GFLAGS_LIBRARIES}
88
108
${GLOG_LIBRARIES}
89
109
${CBLAS_LIBRARIES}
90
110
${PROTOBUF_LIBRARY}
91
111
${ZLIB_LIBRARIES}
112
+ ${PYTHON_LIBRARIES}
92
113
)
93
114
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
+
94
122
add_subdirectory (proto)
95
123
add_subdirectory (paddle)
96
124
add_subdirectory (python)
0 commit comments