-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
188 lines (156 loc) · 5.15 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
cmake_minimum_required(VERSION 3.0.2)
project(adi_tmc_coe)
## Compile as C++11, supported in ROS Kinetic and newer
add_compile_options(-std=c++11)
## 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
geometry_msgs
message_generation
roscpp
std_msgs
roscpp_serialization
soem
)
#################################
## Getting User Configurations ##
#################################
option(TMC_COE_ROS_DEBUG "Show ROS Debug Stream of tmc_coe_ros" OFF)
IF(TMC_COE_ROS_DEBUG)
add_definitions(-DDEBUG)
MESSAGE(STATUS "TMC_COE_ROS_DEBUG is enabled")
ELSE()
MESSAGE(STATUS "TMC_COE_ROS_DEBUG is disabled")
ENDIF(TMC_COE_ROS_DEBUG)
################################################
## Declare ROS messages, services and actions ##
################################################
## Generate messages in the 'msg' folder
add_message_files(
FILES
TmcCoeInfo.msg
)
## Generate services in the 'srv' folder
add_service_files(
FILES
read_write_SDO.srv
read_write_PDO.srv
state_change.srv
CSx_mode.srv
)
## Generate added messages and services with any dependencies listed here
generate_messages(
DEPENDENCIES
std_msgs
)
###################################
## catkin specific configuration ##
###################################
catkin_package(
INCLUDE_DIRS include
LIBRARIES
tmc_coe_interpreter
tmc_coe_motor
tmc_coe_bldc_motor
tmc_coe_stepper_motor
tmc_coe_ros
CATKIN_DEPENDS
roscpp
std_msgs
geometry_msgs
roscpp_serialization
# DEPENDS system_lib
)
# needed to circumvent LD_LIBRARY_PATH being emptied through ethercat_grant
# in addition to not propagating ros_ethercat_loop RUNPATH to dependencies, in contrast to RPATH
SET(GCC_NEWDTAGS_LINK_FLAGS "-Wl,--disable-new-dtags")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_NEWDTAGS_LINK_FLAGS}")
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
###########
## Build ##
###########
## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
include/${PROJECT_NAME}
${catkin_INCLUDE_DIRS}
${soem_INCLUDE_DIRS}
)
## Declare a C++ Libraries
### tmc_coe_interpreter Library
add_library(tmc_coe_interpreter src/tmc_coe_interpreter.cpp)
target_link_libraries(tmc_coe_interpreter ${soem_LIBRARIES})
### tmc_coe_motor Library
add_library(tmc_coe_motor src/tmc_coe_motor.cpp)
add_dependencies(tmc_coe_motor ${PROJECT_NAME}_generate_messages_cpp tmc_coe_interpreter)
target_link_libraries(tmc_coe_motor tmc_coe_interpreter)
### tmc_coe_bldc_motor Library
add_library(tmc_coe_bldc_motor src/tmc_coe_bldc_motor.cpp)
add_dependencies(tmc_coe_bldc_motor ${PROJECT_NAME}_generate_messages_cpp tmc_coe_motor tmc_coe_interpreter)
target_link_libraries(tmc_coe_bldc_motor tmc_coe_motor tmc_coe_interpreter)
### tmc_coe_stepper_motor Library
add_library(tmc_coe_stepper_motor src/tmc_coe_stepper_motor.cpp)
add_dependencies(tmc_coe_stepper_motor ${PROJECT_NAME}_generate_messages_cpp tmc_coe_motor tmc_coe_interpreter)
target_link_libraries(tmc_coe_bldc_motor tmc_coe_motor tmc_coe_interpreter)
### tmc_coe_ros Library
add_library(tmc_coe_ros src/tmc_coe_ros.cpp)
add_dependencies(tmc_coe_ros ${PROJECT_NAME}_generate_messages_cpp tmc_coe_motor tmc_coe_bldc_motor tmc_coe_stepper_motor tmc_coe_interpreter)
add_dependencies(tmc_coe_ros ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(tmc_coe_ros tmc_coe_interpreter)
target_link_libraries(tmc_coe_ros tmc_coe_motor)
target_link_libraries(tmc_coe_ros tmc_coe_bldc_motor)
target_link_libraries(tmc_coe_ros tmc_coe_stepper_motor)
## Declare a C++ executable
### tmc_coe_ros_node Executable
add_executable(tmc_coe_ros_node src/tmc_coe_ros_node.cpp)
target_link_libraries(tmc_coe_ros_node tmc_coe_ros ${catkin_LIBRARIES})
add_dependencies(tmc_coe_ros_node ${PROJECT_NAME}_generate_messages_cpp)
#############
## Install ##
#############
## Mark executables for installation
install(TARGETS tmc_coe_ros_node
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
## Mark libaries for installation
install(TARGETS
tmc_coe_interpreter
tmc_coe_ros
tmc_coe_motor
tmc_coe_bldc_motor
tmc_coe_stepper_motor
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
)
## Mark cpp header files for installation
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.h"
PATTERN ".svn" EXCLUDE
)
## Mark other files for installation (e.g. launch and bag files, etc.)
install(DIRECTORY
launch/
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch
FILES_MATCHING PATTERN "*.launch"
)
install(DIRECTORY
config/
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/config
FILES_MATCHING PATTERN "*.yaml"
)
install(DIRECTORY
scripts/
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/scripts
FILES_MATCHING PATTERN "*.sh"
)
install(FILES
LICENSE
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)
#############
## Testing ##
#############
# N/A