-
Notifications
You must be signed in to change notification settings - Fork 44
/
CMakeLists.txt
243 lines (211 loc) · 7.78 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
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
project(photo-slam LANGUAGES CXX CUDA)
if(NOT CMAKE_BUILD_TYPE)
# set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CUDA_STANDARD 17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
set(CAFFE2_USE_CUDNN on)
# Uncomment the following line if you want to solve CMake Warning "Failed to compute shorthash for libnvrtc.so"
# set(PYTHON_EXECUTABLE "/usr/bin/python3")
find_package(Torch REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS} -pthread")
# set(ENV{CUDA_LAUNCH_BLOCKING} 1)
# set(ENV{TORCH_USE_CUDA_DSA} 1)
find_package(CUDA REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(OpenCV 4 REQUIRED)
find_package(jsoncpp REQUIRED)
find_package(OpenGL REQUIRED)
find_package(glm REQUIRED)
find_package(glfw3 REQUIRED)
find_package(realsense2)
set(ORB_SLAM3_SOURCE_DIR "${PROJECT_SOURCE_DIR}/ORB-SLAM3")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
include_directories(
${PROJECT_SOURCE_DIR}
${ORB_SLAM3_SOURCE_DIR}
${ORB_SLAM3_SOURCE_DIR}/include
${ORB_SLAM3_SOURCE_DIR}/include/CameraModels
${ORB_SLAM3_SOURCE_DIR}/Thirdparty/Sophus
${EIGEN3_INCLUDE_DIR}
${OPENGL_INCLUDE_DIR})
##################################################################################
## Build the gaussian splatting component libraries to ${PROJECT_SOURCE_DIR}/lib
##################################################################################
add_library(simple_knn SHARED
third_party/simple-knn/simple_knn.cu
third_party/simple-knn/simple_knn.h
third_party/simple-knn/spatial.cu
third_party/simple-knn/spatial.h)
# target_compile_features(simple_knn PUBLIC cxx_std_17)
target_link_libraries(simple_knn "${TORCH_LIBRARIES}")
add_library(cuda_rasterizer SHARED
include/operate_points.h
src/operate_points.cu
include/rasterize_points.h
src/rasterize_points.cu
include/stereo_vision.h
src/stereo_vision.cu
cuda_rasterizer/auxiliary.h
cuda_rasterizer/backward.cu
cuda_rasterizer/backward.h
cuda_rasterizer/config.h
cuda_rasterizer/forward.cu
cuda_rasterizer/forward.h
cuda_rasterizer/operate_points.h
cuda_rasterizer/rasterizer.h
cuda_rasterizer/rasterizer_impl.cu
cuda_rasterizer/rasterizer_impl.h
cuda_rasterizer/stereo_vision.h)
set_target_properties(cuda_rasterizer PROPERTIES CUDA_ARCHITECTURES "75;86")
# target_compile_features(cuda_rasterizer PUBLIC cxx_std_17)
target_include_directories(cuda_rasterizer PRIVATE
${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
target_link_libraries(cuda_rasterizer
glm::glm
"${TORCH_LIBRARIES}"
Eigen3::Eigen)
##################################################################################
## Build the ImGui library to ${PROJECT_SOURCE_DIR}/lib
##################################################################################
add_library(imgui SHARED
viewer/imgui/imconfig.h
viewer/imgui/imgui_demo.cpp
viewer/imgui/imgui_draw.cpp
viewer/imgui/imgui_impl_glfw.cpp
viewer/imgui/imgui_impl_glfw.h
viewer/imgui/imgui_impl_opengl3_loader.h
viewer/imgui/imgui_impl_opengl3.cpp
viewer/imgui/imgui_impl_opengl3.h
viewer/imgui/imgui_internal.h
viewer/imgui/imgui_tables.cpp
viewer/imgui/imgui_widgets.cpp
viewer/imgui/imgui.cpp
viewer/imgui/imgui.h
viewer/imgui/imstb_rectpack.h
viewer/imgui/imstb_textedit.h
viewer/imgui/imstb_truetype.h)
target_link_libraries(imgui glfw OpenGL::GL)
##################################################################################
## Build the gaussian mapper library to ${PROJECT_SOURCE_DIR}/lib
##################################################################################
add_library(gaussian_mapper SHARED
third_party/tinyply/tinyply.h
third_party/tinyply/tinyply.cpp
include/gaussian_keyframe.h
include/gaussian_model.h
include/gaussian_parameters.h
include/gaussian_rasterizer.h
include/gaussian_renderer.h
include/gaussian_scene.h
include/gaussian_trainer.h
include/gaussian_mapper.h
include/general_utils.h
include/graphics_utils.h
include/loss_utils.h
include/sh_utils.h
include/tensor_utils.h
include/camera.h
include/point_cloud.h
include/point2d.h
include/point3d.h
include/types.h
src/gaussian_keyframe.cpp
src/gaussian_model.cpp
src/gaussian_parameters.cpp
src/gaussian_rasterizer.cpp
src/gaussian_renderer.cpp
src/gaussian_scene.cpp
src/gaussian_trainer.cpp
src/gaussian_mapper.cpp)
target_link_libraries(gaussian_mapper
${ORB_SLAM3_SOURCE_DIR}/lib/libORB_SLAM3.so
${OpenCV_LIBRARIES}
jsoncpp_lib
"${TORCH_LIBRARIES}"
Eigen3::Eigen
simple_knn
cuda_rasterizer)
##################################################################################
## Build the viewer library to ${PROJECT_SOURCE_DIR}/lib
##################################################################################
add_library(gaussian_viewer SHARED
viewer/drawer_utils.h
viewer/imgui_viewer.cpp
viewer/imgui_viewer.h
viewer/map_drawer.cpp
viewer/map_drawer.h)
target_link_libraries(gaussian_viewer
${ORB_SLAM3_SOURCE_DIR}/lib/libORB_SLAM3.so
gaussian_mapper
imgui
${OpenCV_LIBRARIES}
jsoncpp_lib
"${TORCH_LIBRARIES}"
glm::glm
glfw
OpenGL::GL)
##################################################################################
## Build the test examples to ${PROJECT_SOURCE_DIR}/bin
##################################################################################
# This is a C++ libtorch implementation of gaussian-splatting (https://github.com/graphdeco-inria/gaussian-splatting)
add_executable(train_colmap examples/train_colmap.cpp)
target_link_libraries(train_colmap
gaussian_viewer
gaussian_mapper)
add_executable(view_result examples/view_result.cpp)
target_link_libraries(view_result
gaussian_viewer
gaussian_mapper)
##################################################################################
## Build the mapping examples to ${PROJECT_SOURCE_DIR}/bin
##################################################################################
# Replica Monocular
add_executable(replica_mono examples/replica_mono.cpp)
target_link_libraries(replica_mono
gaussian_viewer
gaussian_mapper
${ORB_SLAM3_SOURCE_DIR}/lib/libORB_SLAM3.so)
# Replica Monocular
add_executable(replica_rgbd examples/replica_rgbd.cpp)
target_link_libraries(replica_rgbd
gaussian_viewer
gaussian_mapper
${ORB_SLAM3_SOURCE_DIR}/lib/libORB_SLAM3.so)
# TUM Monocular
add_executable(tum_mono examples/tum_mono.cpp)
target_link_libraries(tum_mono
gaussian_viewer
gaussian_mapper
${ORB_SLAM3_SOURCE_DIR}/lib/libORB_SLAM3.so)
# TUM RGBD
add_executable(tum_rgbd examples/tum_rgbd.cpp)
target_link_libraries(tum_rgbd
gaussian_viewer
gaussian_mapper
${ORB_SLAM3_SOURCE_DIR}/lib/libORB_SLAM3.so)
# EuRoC Stereo
add_executable(euroc_stereo examples/euroc_stereo.cpp)
target_link_libraries(euroc_stereo
gaussian_viewer
gaussian_mapper
${ORB_SLAM3_SOURCE_DIR}/lib/libORB_SLAM3.so)
##################################################################################
## Build the mapping examples to ${PROJECT_SOURCE_DIR}/bin
##################################################################################
# Intel Realsense
if(realsense2_FOUND)
add_executable(realsense_rgbd examples/realsense_rgbd.cpp)
target_include_directories(realsense_rgbd PUBLIC
${realsense_INCLUDE_DIR})
target_link_libraries(realsense_rgbd
gaussian_viewer
gaussian_mapper
${ORB_SLAM3_SOURCE_DIR}/lib/libORB_SLAM3.so
${realsense2_LIBRARY})
endif()