-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
274 lines (233 loc) · 6.72 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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# set(CMAKE_OSX_SYSROOT "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk")
# We use cmake 3.10 version
cmake_minimum_required(VERSION 3.10)
set(CMAKE_BUILD_TYPE Debug)
# Let's use C++11. For example, GoogleTest requires at least C++11
set(CMAKE_CXX_STANDARD 11)
# Different configurations for debug and release, let us look professional
set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE TYPE INTERNAL FORCE)
IF(CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0")
ENDIF(CMAKE_COMPILER_IS_GNUCC)
# Create compile_commands.json in build for visual studio code
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Our project name
project(kinect_fusion_project)
# Find important libraries
find_package(OpenCV REQUIRED)
find_package(Eigen3 REQUIRED)
# Set variables here
set(LIBRARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libs CACHE PATH "Path to lib folder")
set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src CACHE PATH "Path to src folder")
#set(FreeImage_LIBRARY_DIR ${LIBRARY_DIR}/FreeImage-3.18.0/Dist/x64/ CACHE PATH "Path to free image library")
if(WIN32)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(FreeImage_INCLUDE_DIR ${LIBRARY_DIR}/FreeImage-3.18.0/Dist/x64/ CACHE PATH "Path to FreeImage header file")
set(FreeImage_LIBRARY_DIR ${LIBRARY_DIR}/FreeImage-3.18.0/Dist/x64/ CACHE PATH "Path to FreeImage .lib/.dll folder")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(FreeImage_INCLUDE_DIR ${LIBRARY_DIR}/FreeImage-3.18.0/Dist/x32/ CACHE PATH "Path to FreeImage header file")
set(FreeImage_LIBRARY_DIR ${LIBRARY_DIR}/FreeImage-3.18.0/Dist/x32/ CACHE PATH "Path to FreeImage .lib/.dll folder")
endif()
endif(WIN32)
set(Eigen3_DIR ${LIBRARY_DIR}/Eigen/share/eigen3/cmake CACHE PATH "Path to installed Eigen")
# Only for Mac OS
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(MAC_OS TRUE)
# Add libraries for Mac OS
include_directories(/usr/local/include)
link_directories(/usr/local/lib)
endif()
# Add source directories for includes
include_directories(${SOURCE_DIR})
include_directories(${SOURCE_DIR}/utils/include) # We need it for legacy code
include_directories(${SOURCE_DIR}/surface_measurement/include)
include_directories(${SOURCE_DIR}/ray_casting/include)
include_directories(${SOURCE_DIR}/surface_reconstruction/include)
include_directories(${SOURCE_DIR}/sensor_pose_estimation/include)
# Define our source files
set(SOURCES ${SOURCE_DIR}/utils/src/free_image_helper.cpp
${SOURCE_DIR}/surface_measurement/src/data_frame.cpp
${SOURCE_DIR}/surface_measurement/src/surface_measurement_utils.cpp)
# Add libraries directories for includes
include_directories(${LIBRARY_DIR}/eigen)
include_directories(${OpenCV_INCLUDE_DIRS})
# Link libraries here
link_directories(${FreeImage_LIBRARY_DIR})
# Add google test library for unit tests
add_subdirectory(${LIBRARY_DIR}/googletest)
enable_testing() # For Google test unit tests
find_package(CUDA 8.0)
IF (CUDA_FOUND)
include_directories("${CUDA_INCLUDE_DIRS}")
# Optional: Specify the arch of your CUDA hardware here
# SET(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};-O3;-std=c++11 -gencode arch=compute_20,code=sm_21)
SET(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};-std=c++11)
MESSAGE("CUDA was found. Hurra!!!!")
set(CUDA_SOURCE_DIR ${SOURCE_DIR}/cuda)
include_directories(${CUDA_SOURCE_DIR})
include_directories(${CUDA_SOURCE_DIR}/utils/include) # We need it for legacy code
include_directories(${CUDA_SOURCE_DIR}/surface_measurement/include)
set(SOURCES ${SOURCES}
${CUDA_SOURCE_DIR}/surface_measurement/src/data_frame_cuda.cu
${CUDA_SOURCE_DIR}/surface_measurement/src/surface_measurement_cuda.cu)
ENDIF ()
# Add executables
add_executable(
SurfaceMeasurementApp # Name
${CMAKE_CURRENT_SOURCE_DIR}/executables/surface_measurement_app.cpp # File
${SOURCES}
)
target_link_libraries(
SurfaceMeasurementApp
freeimage
Eigen3::Eigen
${OpenCV_LIBS}
)
add_executable(
PoseEstimationApp # Name
${CMAKE_CURRENT_SOURCE_DIR}/executables/pose_estimation_app.cpp # File
${SOURCES}
)
target_link_libraries(
PoseEstimationApp
freeimage
Eigen3::Eigen
${OpenCV_LIBS}
)
add_executable(
KinectFusionApp # Name
${CMAKE_CURRENT_SOURCE_DIR}/executables/main.cpp # File
${SOURCES}
)
target_link_libraries(
KinectFusionApp
freeimage
Eigen3::Eigen
${OpenCV_LIBS}
)
# Add tests
add_executable(
DataPipelineTest # Test name
test/data_pipeline_test.cpp # Test file
${SOURCES}
)
add_executable(
PoseEstimatorTest # Test name
test/pose_estimator_test.cpp # Test file
${SOURCES}
)
add_executable(
RayTest
test/ray_test.cpp
${SOURCES}
)
add_executable(
CameraTest
test/camera_test.cpp
${SOURCES}
)
add_executable(
SurfaceTest
test/surface_test.cpp
${SOURCES}
)
add_executable(
RayCastingTest
test/ray_casting_test.cpp
${SOURCES}
)
add_executable(
VoxelTest # Test name
test/voxel_test.cpp # Test file
${SOURCES}
)
add_executable(
ReconstructTest
test/recon_test.cpp
${SOURCES}
)
add_executable(
SurfaceMeasurementTest
test/surface_measurement_test.cpp
${SOURCES}
)
# Link test with google test library
target_link_libraries(
DataPipelineTest # Our test
gtest # Google Test library
gtest_main
Eigen3::Eigen
freeimage
${OpenCV_LIBS}
)
target_link_libraries(
PoseEstimatorTest # Our test
gtest # Google Test library
gtest_main
Eigen3::Eigen
freeimage
${OpenCV_LIBS}
)
target_link_libraries(
ReconstructTest # Our test
gtest # Google Test library
gtest_main
Eigen3::Eigen
freeimage
${OpenCV_LIBS}
)
target_link_libraries(
RayTest # Out test
gtest # Google Test library
gtest_main
freeimage
Eigen3::Eigen
${OpenCV_LIBS}
)
target_link_libraries(
CameraTest # Out test
gtest # Google Test library
gtest_main
freeimage
Eigen3::Eigen
${OpenCV_LIBS}
)
target_link_libraries(
SurfaceTest # Out test
gtest # Google Test library
gtest_main
freeimage
Eigen3::Eigen
${OpenCV_LIBS}
)
target_link_libraries(
RayCastingTest # Out test
gtest # Google Test library
gtest_main
freeimage
Eigen3::Eigen
${OpenCV_LIBS}
)
target_link_libraries(
VoxelTest # Out test
gtest # Google Test library
gtest_main
freeimage
Eigen3::Eigen
${OpenCV_LIBS}
)
target_link_libraries(
SurfaceMeasurementTest
gtest # Google Test library
gtest_main
freeimage
Eigen3::Eigen
${OpenCV_LIBS}
)
# Yes, we have tests!
include(GoogleTest)
enable_testing()
gtest_discover_tests(DataPipelineTest)
gtest_discover_tests(SurfaceMeasurementTest)
# gtest_discover_tests(ReconstructTest)