-
Notifications
You must be signed in to change notification settings - Fork 319
/
CMakeLists.txt
190 lines (168 loc) · 4.76 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
cmake_minimum_required(VERSION 3.10.0)
project(fast_gicp)
option(BUILD_VGICP_CUDA "Build GPU-powered VGICP" OFF)
option(BUILD_apps "Build application programs" ON)
option(BUILD_test "Build test programs" OFF)
option(BUILD_PYTHON_BINDINGS "Build python bindings" OFF)
set(CMAKE_BUILD_TYPE "Release")
find_package(PCL REQUIRED)
find_package(Eigen3 REQUIRED)
add_definitions(${PCL_DEFINITIONS})
if(DEFINED ENV{ROS_VERSION})
set(ROS_VERSION $ENV{ROS_VERSION})
endif()
if(NOT BUILD_PYTHON_BINDINGS)
if(${ROS_VERSION})
if(${ROS_VERSION} EQUAL 1)
find_package(catkin)
elseif (${ROS_VERSION} EQUAL 2)
find_package(ament_cmake)
endif()
endif()
endif()
find_package(OpenMP)
if (OPENMP_FOUND)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
if(BUILD_VGICP_CUDA)
find_package(CUDA REQUIRED)
include_directories(${CUDA_INCLUDE_DIRS})
link_directories(${CUDA_LIBRARY_DIRS})
endif()
###################################
## catkin specific configuration ##
###################################
if(catkin_FOUND)
catkin_package(
INCLUDE_DIRS include
LIBRARIES fast_gicp
)
endif()
###########
## Build ##
###########
add_library(fast_gicp SHARED
src/fast_gicp/gicp/lsq_registration.cpp
src/fast_gicp/gicp/fast_gicp.cpp
src/fast_gicp/gicp/fast_gicp_st.cpp
src/fast_gicp/gicp/fast_vgicp.cpp
)
target_link_libraries(fast_gicp
${PCL_LIBRARIES}
)
if (OPENMP_FOUND)
if (TARGET OpenMP::OpenMP_CXX)
target_link_libraries(fast_gicp OpenMP::OpenMP_CXX)
endif ()
endif ()
target_include_directories(fast_gicp PUBLIC
include
${PCL_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIR}
)
### APPS ###
if(BUILD_apps)
add_executable(gicp_align src/align.cpp)
add_dependencies(gicp_align fast_gicp)
target_link_libraries(gicp_align
${PCL_LIBRARIES}
fast_gicp
)
add_executable(gicp_kitti src/kitti.cpp)
add_dependencies(gicp_kitti fast_gicp)
target_link_libraries(gicp_kitti
${PCL_LIBRARIES}
fast_gicp
)
endif()
### Python bindings ###
if(BUILD_PYTHON_BINDINGS)
add_subdirectory(thirdparty/pybind11)
pybind11_add_module(pygicp
src/python/main.cpp
)
target_include_directories(pygicp PUBLIC
include
${PCL_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIR}
)
target_link_libraries(pygicp PRIVATE
fast_gicp
)
endif()
### CUDA ###
if(BUILD_VGICP_CUDA)
set(CUDA_NVCC_FLAGS "--expt-relaxed-constexpr")
add_definitions(-DUSE_VGICP_CUDA)
cuda_add_library(fast_vgicp_cuda SHARED
src/fast_gicp/cuda/fast_vgicp_cuda.cu
src/fast_gicp/cuda/brute_force_knn.cu
src/fast_gicp/cuda/covariance_estimation.cu
src/fast_gicp/cuda/covariance_estimation_rbf.cu
src/fast_gicp/cuda/covariance_regularization.cu
src/fast_gicp/cuda/gaussian_voxelmap.cu
src/fast_gicp/cuda/find_voxel_correspondences.cu
src/fast_gicp/cuda/compute_derivatives.cu
src/fast_gicp/cuda/compute_mahalanobis.cu
src/fast_gicp/cuda/ndt_cuda.cu
src/fast_gicp/cuda/ndt_compute_derivatives.cu
)
target_include_directories(fast_vgicp_cuda PRIVATE
include
thirdparty/Eigen
thirdparty/nvbio
${catkin_INCLUDE_DIRS}
)
target_link_libraries(fast_vgicp_cuda
${catkin_LIBRARIES}
)
cuda_add_cublas_to_target(fast_vgicp_cuda)
# add vgicp_cuda to libfast_gicp
target_sources(fast_gicp PRIVATE
src/fast_gicp/gicp/fast_vgicp_cuda.cpp
src/fast_gicp/ndt/ndt_cuda.cpp
)
target_link_libraries(fast_gicp
fast_vgicp_cuda
)
add_dependencies(fast_gicp fast_vgicp_cuda)
if(catkin_FOUND)
install(TARGETS fast_vgicp_cuda
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION})
elseif (ament_cmake_FOUND)
install(TARGETS fast_vgicp_cuda
LIBRARY DESTINATION lib)
endif()
endif()
### TEST ###
if(BUILD_test)
find_package(GTest REQUIRED)
add_executable(gicp_test src/test/gicp_test.cpp)
add_dependencies(gicp_test fast_gicp)
target_link_libraries(gicp_test ${GTEST_LIBRARIES} ${PCL_LIBRARIES} fast_gicp)
gtest_add_tests(TARGET gicp_test WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} EXTRA_ARGS "${CMAKE_SOURCE_DIR}/data")
endif()
if(catkin_FOUND)
###################################
## catkin specific configuration ##
###################################
install(TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION})
install(DIRECTORY include/
DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.hpp")
elseif (ament_cmake_FOUND)
##################################
## ament specific configuration ##
##################################
ament_export_include_directories(include)
ament_export_libraries(fast_gicp)
ament_package()
install(TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION lib)
install(
DIRECTORY "include/"
DESTINATION include
)
endif()