-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathCMakeLists.txt
206 lines (164 loc) · 5.03 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
cmake_minimum_required(VERSION 3.5)
project(mrs_uav_controllers)
set(CATKIN_DEPENDENCIES
cmake_modules
dynamic_reconfigure
geometry_msgs
mrs_lib
mrs_msgs
mrs_uav_managers
pluginlib
roscpp
rospy
mrs_uav_testing
)
find_package(catkin REQUIRED COMPONENTS
${CATKIN_DEPENDENCIES}
)
generate_dynamic_reconfigure_options(
cfg/se3_controller.cfg
cfg/mpc_controller.cfg
)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_definitions(-Wall)
add_definitions(-Wextra)
if(COVERAGE)
message(WARNING "building with --coverage, the performance might be limited")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
endif()
add_definitions(-Wall)
add_definitions(-Wextra)
add_definitions(-Wpedantic)
find_package(Eigen3 REQUIRED)
set(Eigen_INCLUDE_DIRS ${EIGEN3_INCLUDE_DIRS})
set(Eigen_LIBRARIES ${Eigen_LIBRARIES})
set(LIBRARIES
MrsUavControllers_Se3Controller
MrsUavControllers_MpcController
MrsUavControllers_FailsafeController
MrsUavControllers_MidairActivationController
)
catkin_package(
INCLUDE_DIRS include
CATKIN_DEPENDS ${CATKIN_DEPENDENCIES}
LIBRARIES ${LIBRARIES}
DEPENDS Eigen
)
include_directories(
include
${catkin_INCLUDE_DIRS}
${dynamic_reconfigure_PACKAGE_PATH}/cmake/cfgbuild.cmake
)
# Mpc Solver Library
# Store in CMAKE_DEB_HOST_ARCH var the current build architecture
execute_process(COMMAND
dpkg-architecture
-qDEB_HOST_ARCH
OUTPUT_VARIABLE
CMAKE_DEB_HOST_ARCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# deduce the library path based on the system architecture
if(${CMAKE_DEB_HOST_ARCH} MATCHES "armhf")
MESSAGE(FATAL_ERROR "Mising MpcControllerSolver.so for armhf")
elseif(${CMAKE_DEB_HOST_ARCH} MATCHES "i386")
MESSAGE(FATAL_ERROR "Mising MpcControllerSolver.so for i386")
elseif(${CMAKE_DEB_HOST_ARCH} MATCHES "x64")
set(MPC_CONTROLLER_SOLVER_BIN ${PROJECT_SOURCE_DIR}/lib/MpcControllerSolver/x64/libMpcControllerSolver.so)
elseif(${CMAKE_DEB_HOST_ARCH} MATCHES "amd64")
set(MPC_CONTROLLER_SOLVER_BIN ${PROJECT_SOURCE_DIR}/lib/MpcControllerSolver/x64/libMpcControllerSolver.so)
elseif(${CMAKE_DEB_HOST_ARCH} MATCHES "arm64")
set(MPC_CONTROLLER_SOLVER_BIN ${PROJECT_SOURCE_DIR}/lib/MpcControllerSolver/arm64/libMpcControllerSolver.so)
else()
MESSAGE(FATAL_ERROR ${CMAKE_DEB_HOST_ARCH})
MESSAGE(FATAL_ERROR "MpcControllerSolver.so has not been selected, check CMakeLists.txt.")
endif()
# SE3 controller
add_library(MrsUavControllers_Se3Controller
src/se3_controller.cpp
src/common.cpp
)
add_dependencies(MrsUavControllers_Se3Controller
${${PROJECT_NAME}_EXPORTED_TARGETS}
${catkin_EXPORTED_TARGETS}
${PROJECT_NAME}_gencfg
)
target_link_libraries(MrsUavControllers_Se3Controller
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
)
# Mpc controller
add_library(MrsUavControllers_MpcController
src/mpc_controller.cpp
src/common.cpp
)
add_dependencies(MrsUavControllers_MpcController
${${PROJECT_NAME}_EXPORTED_TARGETS}
${catkin_EXPORTED_TARGETS}
${PROJECT_NAME}_gencfg
)
target_link_libraries(MrsUavControllers_MpcController
${catkin_LIBRARIES}
${MPC_CONTROLLER_SOLVER_BIN}
${Eigen_LIBRARIES}
)
# Failsafe controller
add_library(MrsUavControllers_FailsafeController
src/failsafe_controller.cpp
src/common.cpp
)
add_dependencies(MrsUavControllers_FailsafeController
${${PROJECT_NAME}_EXPORTED_TARGETS}
${catkin_EXPORTED_TARGETS}
)
target_link_libraries(MrsUavControllers_FailsafeController
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
)
# Midair Activation Controller
add_library(MrsUavControllers_MidairActivationController
src/midair_activation_controller.cpp
src/common.cpp
)
add_dependencies(MrsUavControllers_MidairActivationController
${${PROJECT_NAME}_EXPORTED_TARGETS}
${catkin_EXPORTED_TARGETS}
)
target_link_libraries(MrsUavControllers_MidairActivationController
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
)
## --------------------------------------------------------------
## | Testing |
## --------------------------------------------------------------
if(CATKIN_ENABLE_TESTING AND MRS_ENABLE_TESTING)
message(WARNING "Testing enabled.")
add_subdirectory(test)
endif()
## --------------------------------------------------------------
## | Install |
## --------------------------------------------------------------
install(TARGETS ${LIBRARIES}
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
)
install(DIRECTORY config
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)
install(FILES ${MPC_CONTROLLER_SOLVER_BIN}
DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
)
install(FILES plugins.xml
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)
install(DIRECTORY scripts/
USE_SOURCE_PERMISSIONS
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
install(DIRECTORY scripts
USE_SOURCE_PERMISSIONS
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)