-
Notifications
You must be signed in to change notification settings - Fork 91
/
CMakeLists.txt
155 lines (128 loc) · 3.93 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
cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)
project(ardupilot_gazebo)
# --------------------------------------------------------------------------- #
# If ament_cmake is found build as an ament package, otherwise ignore.
# This is so the system may be built for Gazebo only, if ROS is not available.
find_package(ament_cmake QUIET)
if(${ament_cmake_FOUND})
message("Building ${PROJECT_NAME} as an `ament_cmake` project.")
endif()
# --------------------------------------------------------------------------- #
# Compile as C++14.
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# --------------------------------------------------------------------------- #
# Find gz-sim and dependencies.
# Harmonic (default)
if("$ENV{GZ_VERSION}" STREQUAL "harmonic" OR NOT DEFINED "ENV{GZ_VERSION}")
find_package(gz-cmake3 REQUIRED)
set(GZ_CMAKE_VER ${gz-cmake3_VERSION_MAJOR})
gz_find_package(gz-common5 REQUIRED)
set(GZ_COMMON_VER ${gz-common5_VERSION_MAJOR})
gz_find_package(gz-rendering8 REQUIRED)
set(GZ_RENDERING_VER ${gz-rendering8_VERSION_MAJOR})
gz_find_package(gz-sim8 REQUIRED)
set(GZ_SIM_VER ${gz-sim8_VERSION_MAJOR})
message(STATUS "Compiling against Gazebo Harmonic")
# Garden
elseif("$ENV{GZ_VERSION}" STREQUAL "garden")
find_package(gz-cmake3 REQUIRED)
set(GZ_CMAKE_VER ${gz-cmake3_VERSION_MAJOR})
gz_find_package(gz-common5 REQUIRED)
set(GZ_COMMON_VER ${gz-common5_VERSION_MAJOR})
gz_find_package(gz-rendering7 REQUIRED)
set(GZ_RENDERING_VER ${gz-rendering7_VERSION_MAJOR})
gz_find_package(gz-sim7 REQUIRED)
set(GZ_SIM_VER ${gz-sim7_VERSION_MAJOR})
message(STATUS "Compiling against Gazebo Garden")
else()
message(FATAL_ERROR "Unsupported GZ_VERSION: $ENV{GZ_VERSION}")
endif()
# --------------------------------------------------------------------------- #
find_package(RapidJSON REQUIRED)
find_package(OpenCV REQUIRED)
pkg_check_modules(GST REQUIRED gstreamer-1.0 gstreamer-app-1.0)
# --------------------------------------------------------------------------- #
# Build plugin.
add_library(ArduPilotPlugin
SHARED
src/ArduPilotPlugin.cc
src/SocketUDP.cc
src/Util.cc
)
target_include_directories(ArduPilotPlugin PRIVATE
include
)
target_link_libraries(ArduPilotPlugin PRIVATE
gz-sim${GZ_SIM_VER}::gz-sim${GZ_SIM_VER}
)
add_library(ParachutePlugin
SHARED
src/ParachutePlugin.cc
)
target_include_directories(ParachutePlugin PRIVATE
include
)
target_link_libraries(ParachutePlugin PRIVATE
gz-sim${GZ_SIM_VER}::gz-sim${GZ_SIM_VER}
)
add_library(CameraZoomPlugin
SHARED
src/CameraZoomPlugin.cc
)
target_include_directories(CameraZoomPlugin PRIVATE
include
)
target_link_libraries(CameraZoomPlugin PRIVATE
gz-common${GZ_COMMON_VER}::gz-common${GZ_COMMON_VER}
gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER}
gz-sim${GZ_SIM_VER}::gz-sim${GZ_SIM_VER}
)
add_library(GstCameraPlugin
SHARED
src/GstCameraPlugin.cc
)
target_include_directories(GstCameraPlugin PRIVATE
include
${OpenCV_INCLUDE_DIRS}
${GST_INCLUDE_DIRS}
)
target_link_libraries(GstCameraPlugin PRIVATE
gz-sim${GZ_SIM_VER}::gz-sim${GZ_SIM_VER}
${OpenCV_LIBS}
${GST_LINK_LIBRARIES}
)
# --------------------------------------------------------------------------- #
# Install.
install(
TARGETS
ArduPilotPlugin
ParachutePlugin
CameraZoomPlugin
GstCameraPlugin
DESTINATION lib/${PROJECT_NAME}
)
install(
DIRECTORY
config/
DESTINATION share/${PROJECT_NAME}/config
)
install(
DIRECTORY
models/
DESTINATION share/${PROJECT_NAME}/models
)
install(
DIRECTORY
worlds/
DESTINATION share/${PROJECT_NAME}/worlds
)
# --------------------------------------------------------------------------- #
# Register as an ament package if ament_cmake is available.
if(${ament_cmake_FOUND})
ament_environment_hooks(
"${CMAKE_CURRENT_SOURCE_DIR}/hooks/${PROJECT_NAME}.dsv.in")
ament_environment_hooks(
"${CMAKE_CURRENT_SOURCE_DIR}/hooks/${PROJECT_NAME}.sh.in")
ament_package()
endif()