-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
134 lines (111 loc) · 2.84 KB
/
CMakeLists.txt
File metadata and controls
134 lines (111 loc) · 2.84 KB
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
cmake_minimum_required(VERSION 3.10)
project(rtp_image_processor)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Platform detection
if(EXISTS "/etc/nv_tegra_release")
set(JETSON_PLATFORM ON)
add_definitions(-DJETSON_PLATFORM)
endif()
# Find ROS2 packages
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_components REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(std_msgs REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(image_transport REQUIRED)
find_package(camera_info_manager REQUIRED)
find_package(OpenCV REQUIRED)
# Dependencies
find_package(PkgConfig REQUIRED)
pkg_check_modules(GST REQUIRED
gstreamer-1.0>=1.14
gstreamer-app-1.0>=1.14
gstreamer-rtp-1.0>=1.14
)
# Source files
set(SOURCES
src/image_processor.cpp
)
# Library creation
add_library(imageprocessor SHARED ${SOURCES})
target_include_directories(imageprocessor
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE
${GST_INCLUDE_DIRS}
)
target_link_libraries(imageprocessor
PRIVATE
${GST_LIBRARIES}
)
target_compile_options(imageprocessor PRIVATE ${GST_CFLAGS_OTHER})
# ROS2 Component library
add_library(rtp_image_processor_component SHARED
src/rtp_image_processor_node.cpp
)
target_include_directories(rtp_image_processor_component
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE
${GST_INCLUDE_DIRS}
${OpenCV_INCLUDE_DIRS}
)
ament_target_dependencies(rtp_image_processor_component
rclcpp
rclcpp_components
sensor_msgs
std_msgs
cv_bridge
image_transport
camera_info_manager
)
target_link_libraries(rtp_image_processor_component
imageprocessor
${GST_LIBRARIES}
${OpenCV_LIBS}
)
rclcpp_components_register_node(
rtp_image_processor_component
PLUGIN "rtp_image_processor::RtpImageProcessorNode"
EXECUTABLE rtp_image_processor_node
)
# Original demo executable
add_executable(image_processor_demo examples/main.cpp)
target_link_libraries(image_processor_demo imageprocessor)
# Installation
install(TARGETS imageprocessor
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
install(DIRECTORY include/
DESTINATION include
)
install(TARGETS
rtp_image_processor_component
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
install(TARGETS
rtp_image_processor_node
image_processor_demo
DESTINATION lib/${PROJECT_NAME}
)
# Install launch files
install(DIRECTORY launch
DESTINATION share/${PROJECT_NAME}
)
# Install config files
install(DIRECTORY config
DESTINATION share/${PROJECT_NAME}
)
# Tests
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
endif()
ament_package()