forked from sniekum/ml_classifiers
-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
206 lines (159 loc) · 4.61 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
project(ml_classifiers)
set(ROS_VERSION $ENV{ROS_VERSION})
# Version-independent instructions
find_package(Eigen3 REQUIRED)
set(Eigen3_INCLUDE_DIRS ${EIGEN3_INCLUDE_DIRS})
add_definitions(${EIGEN3_DEFINITIONS})
if(${ROS_VERSION} EQUAL 1)
cmake_minimum_required(VERSION 2.8.3)
# Default to C++11
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
endif()
find_package(catkin REQUIRED
COMPONENTS
message_generation
std_msgs
roscpp
pluginlib
)
include_directories(
include
src
${EIGEN3_INCLUDE_DIRS}
${catkin_INCLUDE_DIRS}
)
add_message_files(FILES
ClassDataPoint.msg
DIRECTORY msg
)
add_service_files(FILES
AddClassData.srv
ClassifyData.srv
ClearClassifier.srv
CreateClassifier.srv
LoadClassifier.srv
SaveClassifier.srv
TrainClassifier.srv
DIRECTORY srv
)
generate_messages(DEPENDENCIES std_msgs)
catkin_package(
DEPENDS Eigen3
CATKIN_DEPENDS message_runtime std_msgs roscpp pluginlib
INCLUDE_DIRS include
LIBRARIES ZeroClassifier NearestNeighborClassifier SVMClassifier
)
elseif(${ROS_VERSION} EQUAL 2)
cmake_minimum_required(VERSION 3.5)
# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
add_definitions(-DPLUGINLIB__DISABLE_BOOST_FUNCTIONS)
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rosidl_default_generators REQUIRED)
find_package(pluginlib REQUIRED)
find_package(std_msgs REQUIRED)
include_directories(
include
src
${EIGEN3_INCLUDE_DIRS}
)
rosidl_generate_interfaces(${PROJECT_NAME}
"msg/ClassDataPoint.msg"
"srv/AddClassData.srv"
"srv/ClassifyData.srv"
"srv/ClearClassifier.srv"
"srv/CreateClassifier.srv"
"srv/LoadClassifier.srv"
"srv/SaveClassifier.srv"
"srv/TrainClassifier.srv"
DEPENDENCIES std_msgs
)
endif()
add_library(NearestNeighborClassifier SHARED
src/nearest_neighbor_classifier.cpp)
add_library(SVMClassifier SHARED
src/svm_classifier.cpp
src/libsvm-3.14/svm.cpp)
add_library(ZeroClassifier SHARED
src/zero_classifier.cpp)
if(${ROS_VERSION} EQUAL 1)
add_executable(classifier_server
nodes/ros1_classifier_server.cpp)
target_link_libraries(classifier_server ${catkin_LIBRARIES})
add_dependencies(classifier_server ${PROJECT_NAME}_generate_messages_cpp)
install(TARGETS classifier_server ZeroClassifier NearestNeighborClassifier SVMClassifier
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
elseif(${ROS_VERSION} EQUAL 2)
add_executable(classifier_server
nodes/ros2_classifier_server.cpp)
ament_target_dependencies(NearestNeighborClassifier
"pluginlib")
ament_target_dependencies(SVMClassifier
"pluginlib")
ament_target_dependencies(ZeroClassifier
"pluginlib")
ament_target_dependencies(classifier_server
"rclcpp"
"pluginlib")
target_link_libraries(classifier_server
${rclcpp_LIBRARIES}
${pluginlib_LIBRARIES})
target_include_directories(classifier_server PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
rosidl_target_interfaces(classifier_server
${PROJECT_NAME}
"rosidl_typesupport_cpp")
install(
DIRECTORY include/
DESTINATION include
)
install(
TARGETS classifier_server
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)
install(
TARGETS SVMClassifier
EXPORT SVMClassifier
LIBRARY DESTINATION lib
INCLUDES DESTINATION include
)
install(
TARGETS NearestNeighborClassifier
EXPORT NearestNeighborClassifier
LIBRARY DESTINATION lib
INCLUDES DESTINATION include
)
install(
TARGETS ZeroClassifier
EXPORT ZeroClassifier
LIBRARY DESTINATION lib
INCLUDES DESTINATION include
)
ament_export_dependencies(rosidl_default_runtime)
ament_export_dependencies(pluginlib)
ament_export_include_directories(include)
ament_export_interfaces(SVMClassifier HAS_LIBRARY_TARGET)
ament_export_interfaces(NearestNeighborClassifier HAS_LIBRARY_TARGET)
ament_export_interfaces(ZeroClassifier HAS_LIBRARY_TARGET)
pluginlib_export_plugin_description_file(ml_classifiers
ros2_default_classifiers_plugin.xml)
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
endif()
ament_package()
endif()