forked from SrikarSiddarth/parachute
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
172 lines (130 loc) · 4.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
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
cmake_policy(SET CMP0042 NEW)
cmake_policy(SET CMP0048 NEW)
cmake_policy(SET CMP0054 NEW)
if (NOT CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "/usr" CACHE STRING "install prefix" FORCE)
endif()
message(STATUS "install-prefix: ${CMAKE_INSTALL_PREFIX}")
project(parachute)
include(GNUInstallDirs)
#######################
## Find Dependencies ##
#######################
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
# set c++11 or higher
#include(EnableC++XX)
## System dependencies are found with CMake's conventions
find_package(catkin REQUIRED COMPONENTS roscpp std_msgs gazebo_ros gazebo_ros_link_attacher)
find_package(Boost 1.58 REQUIRED COMPONENTS system thread filesystem)
find_package(gazebo REQUIRED)
find_package(PkgConfig REQUIRED)
# Note: If using catkin, Python 2 is found since it points
# to the Python libs installed with the ROS distro
if (NOT CATKIN_DEVEL_PREFIX)
find_package(PythonInterp 3 REQUIRED)
else()
find_package(PythonInterp REQUIRED)
endif()
pkg_check_modules(OGRE OGRE)
if("${GAZEBO_VERSION}" VERSION_LESS "8.0")
include_directories(SYSTEM ${GAZEBO_INCLUDE_DIRS})
else()
include_directories(SYSTEM ${GAZEBO_INCLUDE_DIRS} ${Qt5Core_INCLUDE_DIRS})
endif()
link_directories(${GAZEBO_LIBRARY_DIRS})
catkin_package(
DEPENDS
gazebo_ros
roscpp
)
catkin_package(
CATKIN_DEPENDS std_msgs gazebo_ros_link_attacher
)
include_directories(include ${catkin_INCLUDE_DIRS})
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()
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()
if("${GAZEBO_VERSION}" VERSION_LESS "6.0")
message(FATAL_ERROR "You need at least Gazebo 6.0. Your version: ${GAZEBO_VERSION}")
else()
message(STATUS "Gazebo version: ${GAZEBO_VERSION}")
endif()
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()
###########
## Build ##
###########
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -Wno-deprecated-declarations -Wno-address-of-packed-member")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations -Wno-address-of-packed-member")
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
${Boost_INCLUDE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${EIGEN3_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIRS}/eigen3 # Workaround for Eigen3
${GAZEBO_INCLUDE_DIRS}
${GAZEBO_MSG_INCLUDE_DIRS}
${MAVLINK_INCLUDE_DIRS}
${OGRE_INCLUDE_DIRS}
${OGRE_INCLUDE_DIRS}/Paging # Workaround for "fatal error: OgrePagedWorldSection.h: No such file or directory"
)
link_libraries(
${Boost_SYSTEM_LIBRARY_RELEASE}
${Boost_THREAD_LIBRARY_RELEASE}
${Boost_TIMER_LIBRARY_RELEASE}
${GAZEBO_LIBRARIES}
# ${OpenCV_LIBRARIES}
${PROTOBUF_LIBRARY}
)
link_directories(
${GAZEBO_LIBRARY_DIRS}
${CMAKE_CURRENT_BINARY_DIR}
${OGRE_LIBRARY_DIRS}
)
#--------------------#
# Message Generation #
#--------------------#
set(physics2_msgs msgs/Wind.proto)
PROTOBUF_GENERATE_CPP(PHY_PROTO_SRCS PHY_PROTO_HDRS ${physics2_msgs})
add_library(physics2_msgs SHARED ${PHY_PROTO_SRCS})
#---------#
# Plugins #
#---------#
link_libraries(physics2_msgs)
add_library(test_parachute SHARED src/gazebo_parachute_plugin.cpp)
set(plugins
test_parachute
)
foreach(plugin ${plugins})
target_link_libraries(${plugin} ${Boost_LIBRARIES} ${GAZEBO_LIBRARIES})
endforeach()
target_link_libraries(test_parachute ${catkin_LIBRARIES})
foreach(plugin ${plugins})
add_dependencies(${plugin} physics2_msgs)
endforeach()