forked from calderpg/common_robotics_utilities
-
Notifications
You must be signed in to change notification settings - Fork 7
/
CMakeLists.txt.ros2
171 lines (141 loc) · 6.32 KB
/
CMakeLists.txt.ros2
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
cmake_minimum_required(VERSION 3.5)
project(common_robotics_utilities)
find_package(ament_cmake_ros REQUIRED)
find_package(rclcpp REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(visualization_msgs REQUIRED)
find_package(Eigen3 REQUIRED)
set(Eigen3_INCLUDE_DIRS ${EIGEN3_INCLUDE_DIR})
find_package(OpenMP)
find_package(ZLIB REQUIRED)
## We don't depend on Drake, but we do use different build flags if present.
find_package(drake QUIET)
###########
## Build ##
###########
## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(include SYSTEM ${Eigen3_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS})
## Build options
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
cmake_policy(SET CMP0069 NEW)
add_compile_options(-std=c++17)
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(-DCOMMON_ROBOTICS_UTILITIES__SUPPORTED_ROS_VERSION=2)
## 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}")
# Utility library
add_library(${PROJECT_NAME}
include/${PROJECT_NAME}/base64_helpers.hpp
include/${PROJECT_NAME}/color_builder.hpp
include/${PROJECT_NAME}/conversions.hpp
include/${PROJECT_NAME}/cru_namespace.hpp
include/${PROJECT_NAME}/dynamic_spatial_hashed_voxel_grid.hpp
include/${PROJECT_NAME}/gaussian_distributions.hpp
include/${PROJECT_NAME}/math.hpp
include/${PROJECT_NAME}/maybe.hpp
include/${PROJECT_NAME}/openmp_helpers.hpp
include/${PROJECT_NAME}/parallelism.hpp
include/${PROJECT_NAME}/path_processing.hpp
include/${PROJECT_NAME}/print.hpp
include/${PROJECT_NAME}/random_rotation_generator.hpp
include/${PROJECT_NAME}/ros_conversions.hpp
include/${PROJECT_NAME}/ros_helpers.hpp
include/${PROJECT_NAME}/serialization.hpp
include/${PROJECT_NAME}/simple_astar_search.hpp
include/${PROJECT_NAME}/simple_dtw.hpp
include/${PROJECT_NAME}/simple_graph.hpp
include/${PROJECT_NAME}/simple_graph_search.hpp
include/${PROJECT_NAME}/simple_hausdorff_distance.hpp
include/${PROJECT_NAME}/simple_hierarchical_clustering.hpp
include/${PROJECT_NAME}/simple_kmeans_clustering.hpp
include/${PROJECT_NAME}/simple_knearest_neighbors.hpp
include/${PROJECT_NAME}/simple_prm_planner.hpp
include/${PROJECT_NAME}/simple_prngs.hpp
include/${PROJECT_NAME}/simple_robot_model_interface.hpp
include/${PROJECT_NAME}/simple_rrt_planner.hpp
include/${PROJECT_NAME}/simple_task_planner.hpp
include/${PROJECT_NAME}/time_optimal_trajectory_parametrization.hpp
include/${PROJECT_NAME}/utility.hpp
include/${PROJECT_NAME}/voxel_grid.hpp
include/${PROJECT_NAME}/zlib_helpers.hpp
src/${PROJECT_NAME}/base64_helpers.cpp
src/${PROJECT_NAME}/conversions.cpp
src/${PROJECT_NAME}/math.cpp
src/${PROJECT_NAME}/ros_conversions.cpp
src/${PROJECT_NAME}/serialization.cpp
src/${PROJECT_NAME}/time_optimal_trajectory_parametrization.cpp
src/${PROJECT_NAME}/zlib_helpers.cpp)
ament_target_dependencies(${PROJECT_NAME} rclcpp geometry_msgs visualization_msgs)
target_link_libraries(${PROJECT_NAME} ${ZLIB_LIBRARIES})
# Examples
add_executable(clustering_example example/clustering_example.cpp)
target_link_libraries(clustering_example ${PROJECT_NAME})
add_executable(dtw_example example/dtw_example.cpp)
target_link_libraries(dtw_example ${PROJECT_NAME})
if(BUILD_TESTING)
# Tests
find_package(ament_cmake_gtest REQUIRED)
ament_add_gtest(hausdorff_distance_test test/hausdorff_distance_test.cpp)
target_link_libraries(hausdorff_distance_test ${PROJECT_NAME})
ament_add_gtest(maybe_test test/maybe_test.cpp)
target_link_libraries(maybe_test ${PROJECT_NAME})
ament_add_gtest(parallelism_test test/parallelism_test.cpp)
target_link_libraries(parallelism_test ${PROJECT_NAME})
ament_add_gtest(planning_test test/planning_test.cpp)
target_link_libraries(planning_test ${PROJECT_NAME})
ament_add_gtest(task_planning_test test/task_planning_test.cpp)
target_link_libraries(task_planning_test ${PROJECT_NAME})
ament_add_gtest(ros_helpers_test test/ros_helpers_test.cpp)
add_dependencies(ros_helpers_test ${PROJECT_NAME})
target_link_libraries(ros_helpers_test ${PROJECT_NAME})
ament_add_gtest(utility_test test/utility_test.cpp)
add_dependencies(utility_test ${PROJECT_NAME})
target_link_libraries(utility_test ${PROJECT_NAME})
ament_add_gtest(voxel_grid_test test/voxel_grid_test.cpp)
target_link_libraries(voxel_grid_test ${PROJECT_NAME})
ament_add_gtest(print_test test/print_test.cpp)
target_link_libraries(print_test ${PROJECT_NAME})
endif()
#############
## Install ##
#############
install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
install(
DIRECTORY include/
DESTINATION include
)
ament_export_definitions(-DCOMMON_ROBOTICS_UTILITIES__SUPPORTED_ROS_VERSION=2)
ament_export_include_directories(include)
ament_export_libraries(${PROJECT_NAME})
ament_export_dependencies(rclcpp)
ament_export_dependencies(geometry_msgs)
ament_export_dependencies(visualization_msgs)
ament_package(CONFIG_EXTRAS cmake/common_robotics_utilities-dependencies.cmake)