forked from jolibrain/deepdetect
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
126 lines (106 loc) · 3.7 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
cmake_minimum_required(VERSION 2.8.8)
project(deepdetect)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include(ExternalProject)
set (deepdetect_VERSION_MAJOR 0)
set (deepdetect_VERSION_MINOR 1)
# options
OPTION(BUILD_TESTS "Should the tests be built")
# Get the current working branch
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Get the latest abbreviated commit hash of the working branch
execute_process(
COMMAND git log -1 --format=%H
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set (CMAKE_CXX_FLAGS "-g -Wall -Wextra -fopenmp -fPIC -std=c++11 -O2 -DUSE_OPENCV -DUSE_LMDB")
# configure a header file to pass some of the CMake settings
# to the source code
configure_file (
"${PROJECT_SOURCE_DIR}/dd_config.h.in"
"${PROJECT_BINARY_DIR}/dd_config.h"
)
configure_file(
"${PROJECT_SOURCE_DIR}/src/githash.h.in"
"${PROJECT_BINARY_DIR}/githash.h"
)
# dependency on Eigen for confusion matrix fast computation
find_package(Eigen3 REQUIRED)
include_directories("${EIGEN3_INCLUDE_DIR}")
# dependency on Boost
find_package(Boost 1.54 REQUIRED COMPONENTS filesystem thread system)
# optional packages
include(cmake/Cuda.cmake) # cuda + cudnn
# customized Caffe as external project
if (CAFFE_INC_DIR AND CAFFE_LIB_DIR)
# do nothing
else()
message(STATUS "Fetching and compiling customized caffe")
if (CUDA_FOUND)
if (HAVE_CUDNN)
ExternalProject_Add(
caffe_dd
PREFIX caffe_dd
INSTALL_DIR ${CMAKE_BINARY_DIR}
URL https://github.com/beniz/caffe/archive/master_dd_integ.tar.gz
CONFIGURE_COMMAND ln -sf Makefile.config.gpu.cudnn Makefile.config && make
INSTALL_COMMAND ""
BUILD_IN_SOURCE 1
)
else()
ExternalProject_Add(
caffe_dd
PREFIX caffe_dd
INSTALL_DIR ${CMAKE_BINARY_DIR}
URL https://github.com/beniz/caffe/archive/master_dd_integ.tar.gz
CONFIGURE_COMMAND ln -sf Makefile.config.gpu Makefile.config && make
INSTALL_COMMAND ""
BUILD_IN_SOURCE 1
)
endif()
else()
ExternalProject_Add(
caffe_dd
PREFIX caffe_dd
INSTALL_DIR ${CMAKE_BINARY_DIR}
URL https://github.com/beniz/caffe/archive/master_dd_integ.tar.gz
CONFIGURE_COMMAND ln -sf Makefile.config.cpu Makefile.config && make
INSTALL_COMMAND ""
BUILD_IN_SOURCE 1
)
endif()
if (CUDA_FOUND)
set(CAFFE_INC_DIR ${CMAKE_BINARY_DIR}/caffe_dd/src/caffe_dd/include ${CMAKE_BINARY_DIR}/caffe_dd/src/caffe_dd/build/src ${CUDA_INCLUDE_DIRS})
set(CAFFE_LIB_DIR ${CMAKE_BINARY_DIR}/caffe_dd/src/caffe_dd/build/lib ${CMAKE_BINARY_DIR}/caffe_dd/src/caffe_dd/build/src /usr/lib/x86_64-linux-gnu/hdf5/serial ${CUDA_LIBRARIES} ${CUDA_CUBLAS_LIBRARIES} ${CUDA_curand_LIBRARY})
else()
set(CAFFE_INC_DIR ${CMAKE_BINARY_DIR}/caffe_dd/src/caffe_dd/include ${CMAKE_BINARY_DIR}/caffe_dd/src/caffe_dd/build/src /usr/include/hdf5/serial)
set(CAFFE_LIB_DIR ${CMAKE_BINARY_DIR}/caffe_dd/src/caffe_dd/build/lib ${CMAKE_BINARY_DIR}/caffe_dd/src/caffe_dd/build/src /usr/lib/x86_64-linux-gnu/hdf5/serial)
endif()
endif()
# add the binary tree to the search path for include files
# so that we will find dd_config.h
include_directories("${PROJECT_BINARY_DIR}")
include_directories("${CAFFE_INC_DIR}")
# main library, main & tests
include_directories ("${PROJECT_SOURCE_DIR}/src")
add_subdirectory (src)
add_subdirectory(main)
# templates
file(COPY "templates" DESTINATION ".")
# examples
file(COPY "examples" DESTINATION ".")
# unit testing
if (BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()
# status
MESSAGE(STATUS "Build Tests : ${BUILD_TESTS}")