-
Notifications
You must be signed in to change notification settings - Fork 24
/
CMakeLists.txt
166 lines (135 loc) · 4.05 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
cmake_minimum_required(VERSION 3.5)
project(ffmpeg_image_transport)
# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
# the image transport api changed between distros
if(DEFINED ENV{ROS_DISTRO})
if($ENV{ROS_DISTRO} STREQUAL "foxy" OR
$ENV{ROS_DISTRO} STREQUAL "galactic")
add_definitions(-DIMAGE_TRANSPORT_API_V1)
elseif($ENV{ROS_DISTRO} STREQUAL "humble")
add_definitions(-DIMAGE_TRANSPORT_API_V2)
else()
add_definitions(-DIMAGE_TRANSPORT_API_V3)
endif()
else()
message(ERROR "ROS_DISTRO environment variable is not set!")
endif()
find_package(ament_cmake REQUIRED)
find_package(ament_cmake_ros REQUIRED)
find_package(image_transport REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(pluginlib REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rcutils REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(std_msgs REQUIRED)
find_package(ffmpeg_image_transport_msgs REQUIRED)
if(${cv_bridge_VERSION} GREATER "3.3.0")
add_definitions(-DUSE_CV_BRIDGE_HPP)
endif()
find_package(OpenCV REQUIRED imgproc)
set(FFMPEG_PKGCONFIG "" CACHE STRING "extra path to pkgconfig")
if("${FFMPEG_PKGCONFIG}" STREQUAL "")
else()
message(WARNING "using FFMPEG package from ${FFMPEG_PKGCONFIG}")
endif()
set(ENV{PKG_CONFIG_PATH} ${FFMPEG_PKGCONFIG})
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBAV REQUIRED IMPORTED_TARGET
libavcodec
libswresample
libswscale
libavutil)
set(LIBRARY_NAME ${PROJECT_NAME}_component)
add_library(
${LIBRARY_NAME}
SHARED
src/ffmpeg_publisher.cpp
src/ffmpeg_subscriber.cpp
src/ffmpeg_encoder.cpp
src/ffmpeg_decoder.cpp
src/tdiff.cpp
src/utils.cpp
src/manifest.cpp)
target_include_directories(${LIBRARY_NAME} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>")
ament_target_dependencies(${LIBRARY_NAME}
PUBLIC
cv_bridge
image_transport
pluginlib
rclcpp
sensor_msgs
ffmpeg_image_transport_msgs)
target_link_libraries(${LIBRARY_NAME}
PUBLIC
opencv_imgproc
PkgConfig::LIBAV)
add_executable(test_encoder
test/test_encoder.cpp)
target_link_libraries(test_encoder ${LIBRARY_NAME})
target_include_directories(test_encoder PRIVATE include)
ament_target_dependencies(test_encoder cv_bridge rclcpp sensor_msgs ffmpeg_image_transport_msgs)
ament_export_dependencies(
OpenCV
LIBAV
cv_bridge
image_transport
pluginlib
rclcpp
rcutils
sensor_msgs
std_msgs
ffmpeg_image_transport_msgs)
install(TARGETS ${LIBRARY_NAME}
EXPORT export_${LIBRARY_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include)
install(TARGETS test_encoder
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
ament_export_include_directories(include)
ament_export_libraries(${LIBRARY_NAME})
ament_export_targets(export_${LIBRARY_NAME} HAS_LIBRARY_TARGET)
install(DIRECTORY
launch
DESTINATION share/${PROJECT_NAME}/
FILES_MATCHING PATTERN "*.py")
install(
DIRECTORY include/
DESTINATION include
)
pluginlib_export_plugin_description_file(image_transport ffmpeg_plugins.xml)
if(BUILD_TESTING)
find_package(ament_cmake REQUIRED)
find_package(ament_cmake_copyright REQUIRED)
find_package(ament_cmake_cppcheck REQUIRED)
find_package(ament_cmake_cpplint REQUIRED)
find_package(ament_cmake_flake8 REQUIRED)
find_package(ament_cmake_lint_cmake REQUIRED)
find_package(ament_cmake_clang_format REQUIRED)
find_package(ament_cmake_xmllint REQUIRED)
if(NOT $ENV{ROS_DISTRO} STREQUAL "galactic")
find_package(ament_cmake_pep257 REQUIRED)
endif()
ament_copyright()
ament_cppcheck(LANGUAGE c++)
ament_cpplint(FILTERS "-build/include,-runtime/indentation_namespace")
ament_flake8()
ament_lint_cmake()
if(NOT $ENV{ROS_DISTRO} STREQUAL "galactic")
ament_pep257()
endif()
ament_clang_format(CONFIG_FILE .clang-format)
ament_xmllint()
endif()
ament_package(CONFIG_EXTRAS cmake/${PROJECT_NAME}-extras.cmake.in)