-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
119 lines (77 loc) · 2.44 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
cmake_minimum_required(VERSION 2.8)
project(deeplcd)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
# colors, because why not :)
string(ASCII 27 Esc)
set(RED "${Esc}[31m")
set(GREEN "${Esc}[32m")
set(ENDL "${Esc}[m")
MESSAGE("${GREEN}Build type: ${CMAKE_BUILD_TYPE}${ENDL}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O3 -march=native ")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O3 -march=native -std=c++11")
set(CMAKE_CXX_FLAGS "-std=c++11 -Wall")
LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules) # FindEigen3.cmake
find_package(Boost COMPONENTS filesystem REQUIRED)
find_package(OpenCV REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(CUDA QUIET)
# option(CPU_ONLY "Build Caffe without CUDA support" ON) # TODO: rename to USE_CUDA
# add_definitions( -DCPU_ONLY=0 )
if (NOT Caffe_ROOT_DIR)
set(Caffe_ROOT_DIR $ENV{HOME}/caffe)
endif()
MESSAGE("${GREEN}Using Caffe_ROOT_DIR: ${Caffe_ROOT_DIR}${ENDL}")
set(Caffe_LIBS ${Caffe_ROOT_DIR}/build/lib/libcaffe.so)
set(Caffe_INCLUDE_DIRS ${Caffe_ROOT_DIR}/build/install/include)
MESSAGE("Caffe_LIBS: ${Caffe_LIBS}")
MESSAGE("Caffe_INCLUDE_DIRS: ${Caffe_INCLUDE_DIRS}")
include_directories(
${OpenCV_INCLUDE_DIR}
${Boost_INLCLUDE_DIRS}
${Caffe_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIR}
${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}
)
if (${CUDA_FOUND})
include_directories(${CUDA_INCLUDE_DIRS})
MESSAGE("CUDA_INCLUDE_DIRS: ${CUDA_INCLUDE_DIRS}")
endif()
file(GLOB SOURCES "src/${PROJECT_NAME}/[A-z]*.cpp")
add_library(${PROJECT_NAME} SHARED
${SOURCES}
)
target_link_libraries(${PROJECT_NAME}
${OpenCV_LIBS}
${Caffe_LIBS}
${Boost_LIBRARIES}
${EIGEN3_LIBS}
glog
pthread
)
if (${CUDA_FOUND})
target_link_libraries(${PROJECT_NAME}
${CUDA_LIBRARIES}
${CUDA_CUBLAS_LIBRARIES}
${CUDA_curand_LIBRARY}
)
endif()
target_include_directories(${PROJECT_NAME} PRIVATE
${Caffe_INCLUDE_DIRS}
)
### Default model download ###########################
message( "\n\n${GREEN}Downloading default model if not already downloaded\n\n${ENDL}" )
execute_process(
COMMAND ./get_model.sh
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
#### Demo ###########################################
# message( "\n\nCopying images and model to build directory for demo and testing....\n\n" )
# execute_process(COMMAND cp -r ../src/images .)
execute_process(COMMAND cp -r ../calc_model .)
add_executable( demo demo/demo.cpp )
target_link_libraries( demo
${PROJECT_NAME}
${OpenCV_LIBS}
)