-
Notifications
You must be signed in to change notification settings - Fork 22
/
CMakeLists.txt
208 lines (183 loc) · 5.21 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
cmake_minimum_required(VERSION 3.0.2)
project(cslibs_mapping CXX)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(cmake/cslibs_mapping_eigen_cpu_flags.cmake)
find_package(catkin REQUIRED COMPONENTS
cslibs_plugins
cslibs_plugins_data
cslibs_gridmaps
cslibs_ndt_2d
cslibs_ndt_3d
cslibs_time
cslibs_utility
cslibs_math
cslibs_math_ros
cslibs_indexed_storage
message_generation
std_msgs
pluginlib
roscpp
)
find_package(Boost REQUIRED COMPONENTS filesystem)
find_package(octomap QUIET)
find_package(yaml-cpp REQUIRED)
find_package(ndt_map QUIET)
add_service_files(
FILES
SaveMap.srv
)
generate_messages(
DEPENDENCIES
std_msgs
)
catkin_package(
INCLUDE_DIRS
include
LIBRARIES
${PROJECT_NAME}_mappers
${PROJECT_NAME}_publishers
CATKIN_DEPENDS
cslibs_plugins
cslibs_plugins_data
cslibs_gridmaps
cslibs_ndt_2d
cslibs_ndt_3d
cslibs_time
cslibs_utility
cslibs_math
cslibs_math_ros
pluginlib
roscpp
CFG_EXTRAS
cslibs_mapping_eigen_cpu_flags.cmake
)
if(NOT ${CMAKE_BUILD_TYPE} STREQUAL Debug)
list(APPEND TARGET_COMPILE_OPTIONS
-Wall -Werror -Ofast -ffast-math
)
# linker flag -rdynamic
# enabling -march=native my result in problems on some machines,
# my try -mtune=native
message(STATUS "[${PROJECT_NAME}]: Compiling with optimization!")
endif()
# basic libs and dirs
set(TARGET_LINK_LIBRARIES
${catkin_LIBRARIES}
${YAML_CPP_LIBRARIES}
)
set(TARGET_INCLUDE_DIRS
include/
${catkin_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${YAML_CPP_INCLUDE_DIRS}
)
# basic src files
set(TARGET_SOURCE_FILES_MAPPERS
src/mapper/ndt_grid_mapper_2d.cpp
src/mapper/ndt_grid_mapper_3d.cpp
src/mapper/occupancy_grid_mapper_2d.cpp
src/mapper/occupancy_ndt_grid_mapper_2d.cpp
src/mapper/occupancy_ndt_grid_mapper_3d.cpp
src/mapper/min_height_mapper_2d.cpp
src/mapper/distribution_height_mapper_2d.cpp
)
set(TARGET_SOURCE_FILES_PUBLISHERS
src/publisher/distributions_publisher.cpp
src/publisher/occupancy_grid_publisher.cpp
src/publisher/pointcloud_publisher.cpp
)
# additional libs, dirs and src files with octomap
if (octomap_FOUND)
# octomap requires octomap_msgs
find_package(octomap_msgs REQUIRED)
list(APPEND TARGET_LINK_LIBRARIES
${OCTOMAP_LIBRARIES}
)
list(APPEND TARGET_INCLUDE_DIRS
${OCTOMAP_INCLUDE_DIRS}
)
list(APPEND TARGET_SOURCE_FILES_MAPPERS
src/mapper/occupancy_grid_mapper_3d.cpp
)
list(APPEND TARGET_SOURCE_FILES_PUBLISHERS
src/publisher/octomap_publisher.cpp
)
endif()
# additional libs, dirs and src files with ndt_map
if (ndt_map_FOUND)
find_package(PCL REQUIRED COMPONENTS common filters segmentation io)
list(APPEND TARGET_LINK_LIBRARIES
${ndt_map_LIBRARIES}
)
list(APPEND TARGET_INCLUDE_DIRS
${ndt_map_INCLUDE_DIRS}
${PCL_INCLUDE_DIRS}
)
list(APPEND TARGET_SOURCE_FILES_MAPPERS
src/mapper/oru_ndt_om_grid_mapper_3d.cpp
src/mapper/oru_ndt_omfg_grid_mapper_3d.cpp
src/mapper/oru_ndt_grid_mapper_3d.cpp
src/mapper/oru_ndt_om_grid_mapper_2d.cpp
src/mapper/oru_ndt_omfg_grid_mapper_2d.cpp
src/mapper/oru_ndt_grid_mapper_2d.cpp
)
list(APPEND TARGET_SOURCE_FILES_PUBLISHERS
src/publisher/oru_publisher.cpp
)
endif()
add_library(${PROJECT_NAME}_mappers
${TARGET_SOURCE_FILES_MAPPERS}
)
target_include_directories(${PROJECT_NAME}_mappers
PRIVATE
${TARGET_INCLUDE_DIRS}
)
target_link_libraries(${PROJECT_NAME}_mappers
PRIVATE
${TARGET_LINK_LIBRARIES}
)
target_compile_options(${PROJECT_NAME}_mappers
PRIVATE
${TARGET_COMPILE_OPTIONS}
)
add_dependencies(${PROJECT_NAME}_mappers ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
add_library(${PROJECT_NAME}_publishers
${TARGET_SOURCE_FILES_PUBLISHERS}
)
target_include_directories(${PROJECT_NAME}_publishers
PRIVATE
${TARGET_INCLUDE_DIRS}
)
target_link_libraries(${PROJECT_NAME}_publishers
PRIVATE
${TARGET_LINK_LIBRARIES}
)
target_compile_options(${PROJECT_NAME}_publishers
PRIVATE
${TARGET_COMPILE_OPTIONS}
)
add_dependencies(${PROJECT_NAME}_publishers ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
add_executable(${PROJECT_NAME}_node
src/nodes/mapping_node.cpp
)
target_include_directories(${PROJECT_NAME}_node
PRIVATE
${TARGET_INCLUDE_DIRS}
)
target_link_libraries(${PROJECT_NAME}_node
PRIVATE
${PROJECT_NAME}_mappers
${PROJECT_NAME}_publishers
${catkin_LIBRARIES}
)
target_compile_options(${PROJECT_NAME}_node
PRIVATE
${TARGET_COMPILE_OPTIONS}
)
install(FILES plugins.xml DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})
install(TARGETS ${PROJECT_NAME}_mappers ${PROJECT_NAME}_publishers #${PROJECT_NAME}_node
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION})
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION})