-
Notifications
You must be signed in to change notification settings - Fork 120
/
CMakeLists.txt
72 lines (61 loc) · 2.31 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
cmake_minimum_required(VERSION 2.8.7)
if(POLICY CMP0046)
cmake_policy(SET CMP0046 NEW)
endif()
if(POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
endif()
set(CAFFE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${CAFFE_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
add_definitions(-DCPU_ONLY)
add_definitions(-DUSE_NEON_MATH)
include(./cmake/Utils.cmake)
include(./cmake/Misc.cmake)
include(./cmake/Targets.cmake)
# Set CXX_FLAGS for different platform
if(NOT MSVC)
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-sign-compare")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wno-sign-compare")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++0x")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++0x")
if(IOS)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fembed-bitcode")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fembed-bitcode")
endif()
endif()
# Set search path for cross compile
if(ANDROID)
STRING(REGEX MATCH "[^ ]+" ANDROID_ABI_PREFIX ${ANDROID_ABI})
set(THIRD_PREFIX ${ANDROID_ABI_PREFIX}-${ANDROID_NATIVE_API_LEVEL}-)
list(INSERT CMAKE_FIND_ROOT_PATH 0 ${CMAKE_SOURCE_DIR}/third_party/${THIRD_PREFIX}protobuf ${CMAKE_SOURCE_DIR}/third_party/${THIRD_PREFIX}OpenBLAS)
elseif(IOS)
list(INSERT CMAKE_FIND_ROOT_PATH 0 ${CMAKE_SOURCE_DIR}/third_party/ios-protobuf)
endif()
#message(STATUS "Change CMAKE_FIND_ROOT_PATH to: ${CMAKE_FIND_ROOT_PATH}")
include(./cmake/ProtoBuf.cmake)
include(./cmake/Modules/FindOpenBLAS.cmake)
include(./cmake/Modules/FindvecLib.cmake)
include(./cmake/Modules/FindAtlas.cmake)
# Select blas lib for different platform
# APPLE only, 1st
if(VECLIB_FOUND)
include_directories(${vecLib_INCLUDE_DIR})
list(APPEND Caffe_LINKER_LIBS ${vecLib_LINKER_LIBS})
elseif(OpenBLAS_FOUND)
include_directories(${OpenBLAS_INCLUDE_DIR})
list(APPEND Caffe_LINKER_LIBS ${OpenBLAS_LIB})
elseif(ATLAS_FOUND)
include_directories(${Atlas_CBLAS_INCLUDE_DIR})
list(APPEND Caffe_LINKER_LIBS ${Atlas_CBLAS_LIBRARY})
else()
MESSAGE(FATAL_ERROR "BLAS (VecLib/OpenBLAS/Atlas) library not found.")
endif()
caffe_set_caffe_link()
add_subdirectory(src/caffe)
if(ANDROID)
add_subdirectory(src/jni)
endif()
if(TOOLS)
add_subdirectory(tools)
endif()