forked from ros-industrial/abb_robot_driver
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
246 lines (205 loc) · 7.19 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
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
cmake_minimum_required(VERSION 3.9.1)
########################################################################################################################
# Metadata
########################################################################################################################
# Read the package manifest.
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/package.xml" package_xml_str)
# Extract project name.
if(NOT package_xml_str MATCHES "<name>([A-Za-z0-9_]+)</name>")
message(FATAL_ERROR "Could not parse project name from package manifest (aborting)")
else()
set(extracted_name ${CMAKE_MATCH_1})
endif()
# Extract project version.
if(NOT package_xml_str MATCHES "<version>([0-9]+.[0-9]+.[0-9]+)</version>")
message(FATAL_ERROR "Could not parse project version from package manifest (aborting)")
else()
set(extracted_version ${CMAKE_MATCH_1})
endif()
########################################################################################################################
# CMake project
########################################################################################################################
project(${extracted_name} VERSION ${extracted_version} LANGUAGES CXX)
#===========================================================
# Dependencies
#===========================================================
#-----------------------------
# ABB robot controller
# communication package
#-----------------------------
find_package(abb_egm_rws_managers REQUIRED)
# Extract include directories, because some subsequent
# catkin packages can't seem to build without this.
get_target_property(abb_libegm_INCLUDE_DIRS ${abb_libegm_LIBRARIES} INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(abb_librws_INCLUDE_DIRS ${abb_librws_LIBRARIES} INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(abb_egm_rws_managers_INCLUDE_DIRS ${abb_egm_rws_managers_LIBRARIES} INTERFACE_INCLUDE_DIRECTORIES)
#-----------------------------
# Catkin packages
#-----------------------------
find_package(catkin REQUIRED
COMPONENTS
abb_robot_cpp_utilities
abb_robot_msgs
controller_manager
controller_manager_msgs
hardware_interface
roscpp
)
#===========================================================
# Catkin package specific configurations
#===========================================================
catkin_package(
INCLUDE_DIRS
include
LIBRARIES
${PROJECT_NAME}_hardware_interface
${PROJECT_NAME}_controller_stopper
CATKIN_DEPENDS
abb_robot_cpp_utilities
abb_robot_msgs
controller_manager
controller_manager_msgs
hardware_interface
roscpp
DEPENDS
abb_egm_rws_managers
abb_libegm
abb_librws
Boost
Poco
Protobuf
)
#===========================================================
# Settings
#===========================================================
if(NOT DEFINED BUILD_SHARED_LIBS)
set(BUILD_SHARED_LIBS ON)
endif()
if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
message(STATUS "${PROJECT_NAME}: Defaulting build type to RelWithDebInfo")
set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif()
#===========================================================
# Build targets (for the ros_control hardware interface)
#===========================================================
set(target_name ${PROJECT_NAME}_hardware_interface)
#-----------------------------
# Library target
#-----------------------------
set(
src_files
src/egm_hardware_interface.cpp
)
add_library(${target_name} ${src_files})
target_include_directories(${target_name} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
"${catkin_INCLUDE_DIRS}"
)
target_link_libraries(${target_name} PUBLIC
abb_egm_rws_managers::abb_egm_rws_managers
${catkin_LIBRARIES}
)
target_compile_features(${target_name} PRIVATE cxx_std_14)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_compile_options(${target_name} PRIVATE -Wall -Wextra -Wpedantic)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
target_compile_options(${target_name} PRIVATE /W4)
endif()
#-----------------------------
# Executable target
#-----------------------------
set(
src_files
src/egm_hardware_interface_main.cpp
)
add_executable(${target_name}_exe ${src_files})
target_include_directories(${target_name}_exe PRIVATE
"${catkin_INCLUDE_DIRS}"
)
target_link_libraries(${target_name}_exe PRIVATE
${catkin_LIBRARIES}
${target_name}
)
target_compile_features(${target_name}_exe PRIVATE cxx_std_14)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_compile_options(${target_name}_exe PRIVATE -Wall -Wextra -Wpedantic)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
target_compile_options(${target_name}_exe PRIVATE /W4)
endif()
set_target_properties(${target_name}_exe
PROPERTIES
OUTPUT_NAME "egm_hardware_interface"
)
#===========================================================
# Build targets (for the stopper of ros_control controllers)
#===========================================================
set(target_name ${PROJECT_NAME}_controller_stopper)
#-----------------------------
# Library target
#-----------------------------
set(
src_files
src/egm_controller_stopper.cpp
)
add_library(${target_name} ${src_files})
target_include_directories(${target_name} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
"${catkin_INCLUDE_DIRS}"
)
target_link_libraries(${target_name} PUBLIC
${catkin_LIBRARIES}
)
target_compile_features(${target_name} PRIVATE cxx_std_14)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_compile_options(${target_name} PRIVATE -Wall -Wextra -Wpedantic)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
target_compile_options(${target_name} PRIVATE /W4)
endif()
#-----------------------------
# Executable target
#-----------------------------
set(
src_files
src/egm_controller_stopper_main.cpp
)
add_executable(${target_name}_exe ${src_files})
target_include_directories(${target_name}_exe PRIVATE
"${catkin_INCLUDE_DIRS}"
)
target_link_libraries(${target_name}_exe PRIVATE
${catkin_LIBRARIES}
${target_name}
)
target_compile_features(${target_name}_exe PRIVATE cxx_std_14)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_compile_options(${target_name}_exe PRIVATE -Wall -Wextra -Wpedantic)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
target_compile_options(${target_name}_exe PRIVATE /W4)
endif()
set_target_properties(${target_name}_exe
PROPERTIES
OUTPUT_NAME "egm_controller_stopper"
)
#===========================================================
# Install
#===========================================================
install(
TARGETS
${PROJECT_NAME}_hardware_interface
${PROJECT_NAME}_hardware_interface_exe
${PROJECT_NAME}_controller_stopper
${PROJECT_NAME}_controller_stopper_exe
ARCHIVE DESTINATION "${CATKIN_PACKAGE_LIB_DESTINATION}"
LIBRARY DESTINATION "${CATKIN_PACKAGE_LIB_DESTINATION}"
RUNTIME DESTINATION "${CATKIN_PACKAGE_BIN_DESTINATION}"
)
install(
DIRECTORY include/${PROJECT_NAME}/
DESTINATION "${CATKIN_PACKAGE_INCLUDE_DESTINATION}"
)
install(
DIRECTORY config launch
DESTINATION "${CATKIN_PACKAGE_SHARE_DESTINATION}"
)