forked from brodyh/caffe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
101 lines (79 loc) · 3.08 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
cmake_minimum_required(VERSION 2.8.8)
project( Caffe )
### Build Options ##########################################################################
option(CPU_ONLY "Build Caffe without GPU support" OFF)
option(USE_CUDNN "Build Caffe with cuDNN support" ON)
option(USE_MPI "Build Caffe with MPI support" ON)
option(BUILD_PYTHON "Build Python wrapper" ON)
option(BUILD_MATLAB "Build Matlab wrapper" OFF)
option(BUILD_EXAMPLES "Build examples" ON)
option(BUILD_SHARED_LIBS "Build SHARED libs if ON and STATIC otherwise" OFF)
if(NOT BLAS)
set(BLAS atlas)
endif()
if(NOT CUDA_TEST_DEVICE)
set(CUDA_TEST_DEVICE -1)
endif()
# Install Prefix
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set (CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Default install path" FORCE )
endif()
#### custom search paths ####
# so it doesn't find older versions of cuda
set(CMAKE_PREFIX_PATH /usr/local/cuda-6.5/bin ${CMAKE_PREFIX_PATH})
# for some reason it had trouble finding this library
set(Atlas_LAPACK_LIBRARY /usr/lib64/atlas/liblapack.so)
### Configuration ###########################################################################
# Compiler Flags
set(CMAKE_CXX_COMPILER_FLAGS ${CMAKE_CXX_COMPILER_FLAGS} -Wall)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -fPIC) # set global flags
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) # set debug flags
set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}) # set release flags
# Global Definitions
if(CPU_ONLY)
add_definitions(-DCPU_ONLY)
endif()
# Include Directories
set(${PROJECT_NAME}_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/include)
include_directories(${${PROJECT_NAME}_INCLUDE_DIRS})
include_directories(${CMAKE_SOURCE_DIR}/src)
# CMake Scripts dir
set(CMAKE_SCRIPT_DIR ${CMAKE_SOURCE_DIR}/CMakeScripts)
# CMake module path for custom module finding
set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SCRIPT_DIR})
# CUDA is required globally
if(NOT CPU_ONLY)
find_package(CUDA 5.5 REQUIRED)
include_directories(${CUDA_INCLUDE_DIRS})
if (USE_CUDNN)
add_definitions(-DUSE_CUDNN)
set(CUDA_CUDNN_LIBRARIES ${CUDA_TOOLKIT_ROOT_DIR}/lib64/libcudnn.so)
endif()
endif()
### Subdirectories ##########################################################################
add_subdirectory(src/gtest)
add_subdirectory(src/caffe)
add_subdirectory(tools)
if(BUILD_EXAMPLES)
message(STATUS "Examples enabled")
add_subdirectory(examples)
endif()
if(BUILD_PYTHON)
message(STATUS "Python enabled")
add_subdirectory(python)
endif()
if(BUILD_MATLAB)
message(STATUS "Matlab enabled")
add_subdirectory(matlab)
endif()
### Lint Target Setup ##########################################################################
set(LINT_TARGET lint)
set(LINT_SCRIPT ${CMAKE_SCRIPT_DIR}/lint.cmake)
add_custom_target(
${LINT_TARGET}
COMMAND ${CMAKE_COMMAND} -P ${LINT_SCRIPT}
)
### Install #################################################################################
# Install Includes
file(GLOB folders ${${PROJECT_NAME}_INCLUDE_DIRS}/*)
install(DIRECTORY ${folders} DESTINATION include)