-
Notifications
You must be signed in to change notification settings - Fork 16
/
CMakeLists.txt.ros1
283 lines (253 loc) · 12.2 KB
/
CMakeLists.txt.ros1
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
273
274
275
276
277
278
279
280
281
282
283
cmake_minimum_required(VERSION 2.8.3)
project(voxelized_geometry_tools)
## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS roscpp
std_msgs
geometry_msgs
visualization_msgs
message_generation
common_robotics_utilities)
find_package(Eigen3 REQUIRED)
set(Eigen3_INCLUDE_DIRS ${EIGEN3_INCLUDE_DIR})
find_package(OpenMP)
find_package(CUDA)
find_package(OpenCL)
## We don't depend on Drake, but we do use different build flags if present.
find_package(drake QUIET)
#######################################
## Declare ROS messages and services ##
#######################################
## Generate messages in the 'msg' folder
add_message_files(DIRECTORY msg
FILES
CollisionMapMessage.msg
DynamicSpatialHashedCollisionMapMessage.msg
SignedDistanceFieldMessage.msg
TaggedObjectCollisionMapMessage.msg)
## Generate added messages and services with any dependencies listed here
generate_messages(DEPENDENCIES geometry_msgs std_msgs)
###################################
## catkin specific configuration ##
###################################
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## LIBRARIES: libraries you create in this project
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project
catkin_package(INCLUDE_DIRS
include
LIBRARIES
${PROJECT_NAME}
${PROJECT_NAME}_pointcloud_voxelization
${PROJECT_NAME}_pointcloud_voxelization_ros_interface
${PROJECT_NAME}_ros_interface
CATKIN_DEPENDS
roscpp
std_msgs
geometry_msgs
visualization_msgs
message_runtime
common_robotics_utilities
DEPENDS
Eigen3
CFG_EXTRAS ${PROJECT_NAME}-extras.cmake)
###########
## Build ##
###########
## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(include SYSTEM ${catkin_INCLUDE_DIRS}
${Eigen3_INCLUDE_DIRS})
## Build options
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
cmake_policy(SET CMP0069 NEW)
add_compile_options(-std=c++11)
add_compile_options(-Wall)
add_compile_options(-Wextra)
add_compile_options(-Werror)
add_compile_options(-Wconversion)
add_compile_options(-Wshadow)
add_compile_options(-O3)
add_compile_options(-g)
add_compile_options(-Werror=non-virtual-dtor)
add_compile_options(-Wold-style-cast)
add_compile_options(-Wpessimizing-move)
add_compile_options(-Wuninitialized)
add_compile_options(-Wmissing-declarations)
if(drake_FOUND)
message(STATUS "Drake found, disabling -march=native")
else()
message(STATUS "Drake NOT found, enabling -march=native")
add_compile_options(-march=native)
endif()
add_definitions(-DVOXELIZED_GEOMETRY_TOOLS__SUPPORTED_ROS_VERSION=1)
## It's not clear if add_compile_options does the right things for flags that
## may differ between languages and target type.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS
"${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS
"${CMAKE_SHARED_LINKER_FLAGS} ${OpenMP_SHARED_LINKER_FLAGS}")
# Voxelized geometry tools library
add_library(${PROJECT_NAME}
include/${PROJECT_NAME}/collision_map.hpp
include/${PROJECT_NAME}/dynamic_spatial_hashed_collision_map.hpp
include/${PROJECT_NAME}/mesh_rasterizer.hpp
include/${PROJECT_NAME}/signed_distance_field.hpp
include/${PROJECT_NAME}/signed_distance_field_generation.hpp
include/${PROJECT_NAME}/tagged_object_collision_map.hpp
include/${PROJECT_NAME}/topology_computation.hpp
src/${PROJECT_NAME}/collision_map.cpp
src/${PROJECT_NAME}/mesh_rasterizer.cpp
src/${PROJECT_NAME}/dynamic_spatial_hashed_collision_map.cpp
src/${PROJECT_NAME}/signed_distance_field.cpp
src/${PROJECT_NAME}/signed_distance_field_generation.cpp
src/${PROJECT_NAME}/tagged_object_collision_map.cpp)
add_dependencies(${PROJECT_NAME} ${catkin_EXPORTED_TARGETS})
target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES})
# Cuda voxelization helpers library
if(CUDA_FOUND)
message(STATUS "CUDA found. Building CUDA voxelization helpers")
include_directories(SYSTEM ${CUDA_INCLUDE_DIRS})
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -std=c++11 -O3 -use_fast_math")
set(CUDA_NVCC_FLAGS
"${CUDA_NVCC_FLAGS} -Xcompiler -D__CORRECT_ISO_CPP11_MATH_H_PROTO")
cuda_add_library(${PROJECT_NAME}_cuda_voxelization_helpers
include/${PROJECT_NAME}/device_voxelization_interface.hpp
include/${PROJECT_NAME}/cuda_voxelization_helpers.h
src/${PROJECT_NAME}/cuda_voxelization_helpers.cu)
target_link_libraries(${PROJECT_NAME}_cuda_voxelization_helpers
cuda ${CUDA_LIBRARIES})
add_library(${PROJECT_NAME}_dummy_cuda_voxelization_helpers
include/${PROJECT_NAME}/device_voxelization_interface.hpp
include/${PROJECT_NAME}/cuda_voxelization_helpers.h
src/${PROJECT_NAME}/dummy_cuda_voxelization_helpers.cc)
else()
message(WARNING "CUDA not found. Building stubs for CUDA helpers.")
add_library(${PROJECT_NAME}_cuda_voxelization_helpers
include/${PROJECT_NAME}/device_voxelization_interface.hpp
include/${PROJECT_NAME}/cuda_voxelization_helpers.h
src/${PROJECT_NAME}/dummy_cuda_voxelization_helpers.cc)
endif()
# OpenCL voxelization helpers library
if(OpenCL_FOUND)
message(STATUS "OpenCL found. Building OpenCL voxelization helpers")
include_directories(SYSTEM ${OpenCL_INCLUDE_DIRS})
add_library(${PROJECT_NAME}_opencl_voxelization_helpers
include/${PROJECT_NAME}/device_voxelization_interface.hpp
include/${PROJECT_NAME}/opencl_voxelization_helpers.h
src/${PROJECT_NAME}/opencl_voxelization_helpers.cc)
target_link_libraries(${PROJECT_NAME}_opencl_voxelization_helpers
${OpenCL_LIBRARIES})
add_library(${PROJECT_NAME}_dummy_opencl_voxelization_helpers
include/${PROJECT_NAME}/device_voxelization_interface.hpp
include/${PROJECT_NAME}/opencl_voxelization_helpers.h
src/${PROJECT_NAME}/dummy_opencl_voxelization_helpers.cc)
else()
message(WARNING "OpenCL not found. Building stubs for OpenCL helpers.")
add_library(${PROJECT_NAME}_opencl_voxelization_helpers
include/${PROJECT_NAME}/device_voxelization_interface.hpp
include/${PROJECT_NAME}/opencl_voxelization_helpers.h
src/${PROJECT_NAME}/dummy_opencl_voxelization_helpers.cc)
endif()
# Pointcloud voxelization
add_library(${PROJECT_NAME}_pointcloud_voxelization
include/${PROJECT_NAME}/cpu_pointcloud_voxelization.hpp
include/${PROJECT_NAME}/device_pointcloud_voxelization.hpp
include/${PROJECT_NAME}/device_voxelization_interface.hpp
include/${PROJECT_NAME}/pointcloud_voxelization_interface.hpp
include/${PROJECT_NAME}/pointcloud_voxelization.hpp
src/${PROJECT_NAME}/cpu_pointcloud_voxelization.cpp
src/${PROJECT_NAME}/device_pointcloud_voxelization.cpp
src/${PROJECT_NAME}/pointcloud_voxelization.cpp)
add_dependencies(${PROJECT_NAME}_pointcloud_voxelization
${catkin_EXPORTED_TARGETS} ${PROJECT_NAME}_gencpp)
target_link_libraries(${PROJECT_NAME}_pointcloud_voxelization
${PROJECT_NAME}_cuda_voxelization_helpers
${PROJECT_NAME}_opencl_voxelization_helpers
${PROJECT_NAME} ${catkin_LIBRARIES})
# ROS interface libraries
add_library(${PROJECT_NAME}_ros_interface
include/${PROJECT_NAME}/ros_interface.hpp
src/${PROJECT_NAME}/ros_interface.cpp)
add_dependencies(${PROJECT_NAME}_ros_interface ${catkin_EXPORTED_TARGETS}
${PROJECT_NAME}_gencpp)
target_link_libraries(${PROJECT_NAME}_ros_interface ${PROJECT_NAME}
${catkin_LIBRARIES})
add_library(${PROJECT_NAME}_pointcloud_voxelization_ros_interface
include/${PROJECT_NAME}/pointcloud_voxelization_ros_interface.hpp
src/${PROJECT_NAME}/pointcloud_voxelization_ros_interface.cpp)
add_dependencies(${PROJECT_NAME}_pointcloud_voxelization_ros_interface
${catkin_EXPORTED_TARGETS} ${PROJECT_NAME}_gencpp)
target_link_libraries(${PROJECT_NAME}_pointcloud_voxelization_ros_interface
${PROJECT_NAME}_pointcloud_voxelization
${catkin_LIBRARIES})
# Examples
add_executable(voxelized_geometry_tools_tutorial example/tutorial.cpp)
add_dependencies(voxelized_geometry_tools_tutorial
${PROJECT_NAME} ${catkin_EXPORTED_TARGETS} ${PROJECT_NAME}_gencpp)
target_link_libraries(voxelized_geometry_tools_tutorial
${PROJECT_NAME}_ros_interface ${PROJECT_NAME} ${catkin_LIBRARIES})
add_executable(estimate_distance_example example/estimate_distance.cpp)
add_dependencies(estimate_distance_example
${PROJECT_NAME} ${catkin_EXPORTED_TARGETS} ${PROJECT_NAME}_gencpp)
target_link_libraries(estimate_distance_example
${PROJECT_NAME}_ros_interface ${PROJECT_NAME} ${catkin_LIBRARIES})
add_executable(spatial_segments example/spatial_segments.cpp)
add_dependencies(spatial_segments
${PROJECT_NAME} ${catkin_EXPORTED_TARGETS} ${PROJECT_NAME}_gencpp)
target_link_libraries(spatial_segments
${PROJECT_NAME}_ros_interface ${PROJECT_NAME} ${catkin_LIBRARIES})
add_executable(pointcloud_voxelization example/pointcloud_voxelization.cpp)
add_dependencies(pointcloud_voxelization
${PROJECT_NAME}_pointcloud_voxelization ${PROJECT_NAME}
${catkin_EXPORTED_TARGETS} ${PROJECT_NAME}_gencpp)
target_link_libraries(pointcloud_voxelization
${PROJECT_NAME}_ros_interface ${PROJECT_NAME}_pointcloud_voxelization
${PROJECT_NAME} ${catkin_LIBRARIES})
if(CATKIN_ENABLE_TESTING)
# Tests
catkin_add_gtest(pointcloud_voxelization_test
test/pointcloud_voxelization_test.cpp)
add_dependencies(pointcloud_voxelization_test
${PROJECT_NAME}_pointcloud_voxelization)
target_link_libraries(pointcloud_voxelization_test
${PROJECT_NAME}_pointcloud_voxelization)
catkin_add_gtest(mesh_rasterization_test test/mesh_rasterization_test.cpp)
add_dependencies(mesh_rasterization_test ${PROJECT_NAME})
target_link_libraries(mesh_rasterization_test ${PROJECT_NAME})
catkin_add_gtest(sdf_generation_test test/sdf_generation_test.cpp)
add_dependencies(sdf_generation_test ${PROJECT_NAME})
target_link_libraries(sdf_generation_test ${PROJECT_NAME})
endif()
#############
## Install ##
#############
## Mark library for installation
install(TARGETS ${PROJECT_NAME}
${PROJECT_NAME}_cuda_voxelization_helpers
${PROJECT_NAME}_opencl_voxelization_helpers
${PROJECT_NAME}_pointcloud_voxelization
${PROJECT_NAME}_pointcloud_voxelization_ros_interface
${PROJECT_NAME}_ros_interface
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
# Mark examples for installation
install(TARGETS
voxelized_geometry_tools_tutorial
estimate_distance_example
spatial_segments
pointcloud_voxelization
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
## Mark cpp header files for installation
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.hpp"
PATTERN ".svn" EXCLUDE
)