-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathCMakeLists.txt
80 lines (67 loc) · 2.3 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
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
# Find Eigen
find_package(Eigen3 QUIET)
if(NOT EIGEN3_FOUND)
# Fallback to cmake_modules
find_package(Eigen QUIET)
if(NOT EIGEN_FOUND)
pkg_check_modules(EIGEN3 REQUIRED eigen3)
else()
set(EIGEN3_INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS})
set(EIGEN3_LIBRARIES ${EIGEN_LIBRARIES})
endif()
else()
set(EIGEN3_INCLUDE_DIRS ${EIGEN3_INCLUDE_DIR})
endif()
find_package(yaml-cpp REQUIRED)
find_package(Boost 1.58 REQUIRED COMPONENTS system thread filesystem)
# Find Gazebo
find_package(gazebo REQUIRED)
add_compile_options(-Wno-deprecated-declarations -Wno-address-of-packed-member)
link_directories(${GAZEBO_LIBRARY_DIRS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GAZEBO_CXX_FLAGS}")
set(PROTOBUF_IMPORT_DIRS "")
foreach(ITR ${GAZEBO_INCLUDE_DIRS})
if(ITR MATCHES ".*gazebo-[0-9.]+$")
set(PROTOBUF_IMPORT_DIRS "${ITR}/gazebo/msgs/proto")
endif()
endforeach()
# PROTOBUF_IMPORT_DIRS has to be set before
# find_package is called
find_package(Protobuf REQUIRED)
pkg_check_modules(PROTOBUF protobuf)
if ("${PROTOBUF_VERSION}" VERSION_LESS "2.5.0")
message(FATAL_ERROR "protobuf version: ${PROTOBUF_VERSION} not compatible, must be >= 2.5.0")
endif()
set(GAZEBO_MSG_INCLUDE_DIRS)
foreach(ITR ${GAZEBO_INCLUDE_DIRS})
if(ITR MATCHES ".*gazebo-[0-9.]+$")
set(GAZEBO_MSG_INCLUDE_DIRS "${ITR}/gazebo/msgs")
endif()
endforeach()
include_directories(
include
${GAZEBO_INCLUDE_DIRS}
${GAZEBO_MSG_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIRS}/eigen3 # Workaround for Eigen3
${YAML_CPP_INCLUDE_DIR}
$ENV{PX4_ROOT}/build/px4_sitl_default/build_gazebo-classic
)
# Build our plugin
add_library(data_driven_dynamics_plugin
SHARED
src/data_driven_dynamics_plugin.cpp
src/parametric_dynamics_model.cpp
)
target_link_libraries(data_driven_dynamics_plugin
${GAZEBO_LIBRARIES}
${Boost_LIBRARIES}
${YAML_CPP_LIBRARIES}
$ENV{PX4_ROOT}/build/px4_sitl_default/build_gazebo-classic/libmav_msgs.so
$ENV{PX4_ROOT}/build/px4_sitl_default/build_gazebo-classic/libnav_msgs.so
$ENV{PX4_ROOT}/build/px4_sitl_default/build_gazebo-classic/libphysics_msgs.so
$ENV{PX4_ROOT}/build/px4_sitl_default/build_gazebo-classic/libsensor_msgs.so
$ENV{PX4_ROOT}/build/px4_sitl_default/build_gazebo-classic/libstd_msgs.so
)
add_subdirectory(unit_tests)