forked from bayesian-object-tracking/dbot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
233 lines (197 loc) · 7.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
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
cmake_minimum_required(VERSION 2.8.3)
project(dbot)
############################
# Options #
############################
option(DBOT_BUILD_GPU "Compile CUDA enabled trackers" ON)
option(DBOT_BUILD_TESTS "Compile tests" OFF)
option(DBOT_BUILD_DOCS "Compile docs" OFF)
############################
# Flags #
############################
# Enable c++11 GCC 4.7 or greater required
add_definitions(-std=c++11 -fno-omit-frame-pointer -fPIC)
add_definitions(-DPROFILING_ON=1) #print profiling output
#add_definitions(-Wall)
#add_definitions(-Wno-unused-local-typedefs)
#add_definitions(-Wno-deprecated-declarations)
#add_definitions(-Wno-comment)
## for eigen-3.1.2
#add_definitions(-Wno-deprecated-register)
############################
# Library Version #
############################
# include(cmake/version.cmake)
############################
# Setup #
############################
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
# local variables
set(dbot_LIBRARY ${PROJECT_NAME})
set(dbot_LIBRARY_GPU ${dbot_LIBRARY}_gpu)
# parent scope variables; exported at the end
set(dbot_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/source)
set(dbot_LIBRARIES ${dbot_LIBRARY})
############################
# Dependencies #
############################
if(NOT TARGET Eigen3::Eigen)
find_package(Eigen3 REQUIRED)
endif()
# include_directories(${EIGEN3_INCLUDE_DIR})
# add_definitions(${EIGEN3_DEFINITIONS})
find_package(Boost REQUIRED COMPONENTS system filesystem)
include_directories(${Boost_INCLUDE_DIRS})
# GPU libs
set(GLEW_DIR ${CMAKE_MODULE_PATH})
find_package(CUDA QUIET)
find_package(GLEW QUIET)
find_package(OpenGL QUIET)
if(DBOT_BUILD_GPU AND CUDA_FOUND AND GLEW_FOUND AND OPENGL_FOUND)
include_directories(${GLEW_INCLUDE_DIRS})
include_directories(${OpenGL_INCLUDE_DIRS})
link_directories(${OpenGL_LIBRARY_DIRS})
link_directories(${GLEW_LIBRARY_DIRS})
add_definitions(${OpenGL_DEFINITIONS})
add_definitions(${GLEW_DEFINITIONS})
# enable cuda debug information with -g -G -O0, to use with cuda-dbg use
# --ptxas-options=-v to see number of registers, local, shared and constant
# memory used in kernels
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -O2 -arch=sm_30)
list(APPEND dbot_LIBRARIES ${dbot_LIBRARY_GPU} ${CUDA_CUDART_LIBRARY})
# activate gpu implementations
add_definitions(-DDBOT_BUILD_GPU=1)
set(DBOT_GPU_SUPPORT "YES")
message(STATUS "Found CUDA version ${CUDA_VERSION_STRING}")
else(DBOT_BUILD_GPU AND CUDA_FOUND AND GLEW_FOUND AND OPENGL_FOUND)
set(DBOT_GPU_SUPPORT "NO")
if(DBOT_BUILD_GPU)
message(WARNING "No CUDA support. Deactivating GPU implementation")
endif(DBOT_BUILD_GPU)
set(DBOT_BUILD_GPU OFF)
endif(DBOT_BUILD_GPU AND CUDA_FOUND AND GLEW_FOUND AND OPENGL_FOUND)
############################
# Library info summary #
############################
#include(cmake/info.cmake)
#info_yesorno(CUDA_FOUND DBOT_FOUND_CUDA)
#info_yesorno(GLEW_FOUND DBOT_FOUND_GLEW)
#info_yesorno(OPENGL_FOUND DBOT_FOUND_OPENGL)
#info_begin()
# info_project("::bot::dbot:: Depth Based Object Tracking Lib" ${PROJECT_VERSION})
# info_header("Setup")
# info_item("Found CUDA" "${DBOT_FOUND_CUDA}")
# info_item("Found GLEW" "${DBOT_FOUND_GLEW}")
# info_item("Found OpenGL" "${DBOT_FOUND_OPENGL}")
# info_item("Compiling with GPU Support" "${DBOT_GPU_SUPPORT}")
#info_end()
############################
# Dependencies #
############################
# Use catkin of available otherwise fall back to native cmake
# find_package(catkin QUIET COMPONENTS fl)
function(init_git_submodule GIT_SUBMODULE)
find_package(Git REQUIRED)
execute_process(
COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive ${GIT_SUBMODULE}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endfunction()
init_git_submodule(fl)
add_subdirectory(fl)
if(DBOT_BUILD_GPU)
list(APPEND dbot_INCLUDE_DIRS ${CUDA_INCLUDE_DIRS})
list(APPEND dbot_INCLUDE_DIRS ${CUDA_CUT_INCLUDE_DIRS})
list(APPEND dbot_INCLUDE_DIRS ${GLEW_INCLUDE_DIRS})
list(APPEND dbot_INCLUDE_DIRS ${OpenGL_INCLUDE_DIR})
endif(DBOT_BUILD_GPU)
# if(catkin_FOUND)
# message(STATUS "Using catkin")
# catkin_package(
# INCLUDE_DIRS
# ${dbot_INCLUDE_DIRS}
# LIBRARIES
# ${dbot_LIBRARIES}
# CATKIN_DEPENDS
# fl
# DEPENDS
# Boost
# # CUDA
# )
# list(APPEND dbot_INCLUDE_DIRS ${catkin_INCLUDE_DIRS})
# else(catkin_FOUND)
# find_package(fl REQUIRED)
# list(APPEND dbot_INCLUDE_DIRS ${fl_INCLUDE_DIRS} source)
# endif(catkin_FOUND)
############################
## dbot library #
############################
set(dbot_SOURCE_DIR source/${PROJECT_NAME})
file(GLOB_RECURSE dbot_HEADERS
${dbot_SOURCE_DIR}/*.hpp
${dbot_SOURCE_DIR}/*.h)
# Build dbot library
set(dbot_SOURCES
${dbot_SOURCE_DIR}/camera_data.cpp
${dbot_SOURCE_DIR}/object_model.cpp
${dbot_SOURCE_DIR}/object_file_reader.cpp
${dbot_SOURCE_DIR}/rigid_body_renderer.cpp
${dbot_SOURCE_DIR}/object_resource_identifier.cpp
${dbot_SOURCE_DIR}/simple_camera_data_provider.cpp
${dbot_SOURCE_DIR}/virtual_camera_data_provider.cpp
${dbot_SOURCE_DIR}/simple_wavefront_object_loader.cpp
${dbot_SOURCE_DIR}/simple_shader_provider.cpp
${dbot_SOURCE_DIR}/default_shader_provider.cpp
${dbot_SOURCE_DIR}/file_shader_provider.cpp
${dbot_SOURCE_DIR}/tracker/tracker.cpp
${dbot_SOURCE_DIR}/tracker/particle_tracker.cpp
${dbot_SOURCE_DIR}/tracker/gaussian_tracker.cpp
${dbot_SOURCE_DIR}/builder/rb_sensor_builder.cpp
${dbot_SOURCE_DIR}/builder/particle_tracker_builder.cpp
${dbot_SOURCE_DIR}/builder/gaussian_tracker_builder.cpp
)
add_library(${dbot_LIBRARY} SHARED
${dbot_HEADERS}
${dbot_SOURCES})
target_include_directories(${dbot_LIBRARY} PUBLIC
${dbot_INCLUDE_DIRS})
target_link_libraries(${dbot_LIBRARY} PUBLIC
Eigen3::Eigen
fl::fl
${Boost_LIBRARIES})
add_library(${dbot_LIBRARY}::${dbot_LIBRARY} ALIAS ${dbot_LIBRARY})
# Build dbot GPU library
if(DBOT_BUILD_GPU)
cuda_add_library(${dbot_LIBRARY_GPU} SHARED
${dbot_SOURCE_DIR}/gpu/cuda_likelihood_evaluator.cu
${dbot_SOURCE_DIR}/gpu/shader.cpp
${dbot_SOURCE_DIR}/gpu/object_rasterizer.cpp
${dbot_SOURCE_DIR}/gpu/buffer_configuration.cpp)
target_include_directories(${dbot_LIBRARY_GPU} PUBLIC
${dbot_INCLUDE_DIRS})
target_link_libraries(${dbot_LIBRARY_GPU} PUBLIC
Eigen3::Eigen
fl::fl
${Boost_LIBRARIES}
${OPENGL_LIBRARIES}
${GLFW_LIBRARY}
${GLEW_LIBRARIES}
${CUDA_CUDART_LIBRARY})
add_library(${dbot_LIBRARY}::${dbot_LIBRARY_GPU} ALIAS ${dbot_LIBRARY_GPU})
else()
add_library(${dbot_LIBRARY}::${dbot_LIBRARY_GPU} ALIAS ${dbot_LIBRARY})
endif(DBOT_BUILD_GPU)
############################
# Tests #
############################
if(DBOT_BUILD_TESTS)
enable_testing()
include(${CMAKE_MODULE_PATH}/gtest.cmake)
include(utests.cmake)
endif()
############################
# Documentation #
############################
if(DBOT_BUILD_DOCS)
include(cmake/doxygen.cmake)
endif()