-
Notifications
You must be signed in to change notification settings - Fork 321
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
197 lines (176 loc) · 5.64 KB
/
Copy pathCMakeLists.txt
File metadata and controls
197 lines (176 loc) · 5.64 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
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
cmake_minimum_required(VERSION 3.20)
project(rosbag2_py)
# Default to C99
if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 99)
endif()
# Default to C++17
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
find_package(ament_cmake REQUIRED)
find_package(ament_cmake_python REQUIRED)
find_package(ament_cmake_ros REQUIRED)
find_package(rosbag2_compression REQUIRED)
find_package(rosbag2_cpp REQUIRED)
find_package(rosbag2_storage REQUIRED)
find_package(rosbag2_transport REQUIRED)
# By default, without the settings below, find_package(Python3) will attempt
# to find the newest python version it can, and additionally will find the
# most specific version. For instance, on a system that has
# /usr/bin/python3.10, /usr/bin/python3.11, and /usr/bin/python3, it will find
# /usr/bin/python3.11, even if /usr/bin/python3 points to /usr/bin/python3.10.
# The behavior we want is to prefer the "system" installed version unless the
# user specifically tells us othewise through the Python3_EXECUTABLE hint.
# Setting CMP0094 to NEW means that the search will stop after the first
# python version is found. Setting Python3_FIND_UNVERSIONED_NAMES means that
# the search will prefer /usr/bin/python3 over /usr/bin/python3.11. And that
# latter functionality is only available in CMake 3.20 or later, so we need
# at least that version.
cmake_policy(SET CMP0094 NEW)
set(Python3_FIND_UNVERSIONED_NAMES FIRST)
# Find python before pybind11
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
find_package(pybind11 REQUIRED)
ament_python_install_package(${PROJECT_NAME})
pybind11_add_module(_compression_options
src/rosbag2_py/_compression_options.cpp
)
target_link_libraries(_compression_options PUBLIC
rosbag2_compression::rosbag2_compression
)
pybind11_add_module(_message_definitions
src/rosbag2_py/_message_definitions.cpp
)
target_link_libraries(_message_definitions PUBLIC
rosbag2_cpp::rosbag2_cpp
)
pybind11_add_module(_reader
src/rosbag2_py/_reader.cpp
)
target_link_libraries(_reader PUBLIC
rosbag2_compression::rosbag2_compression
rosbag2_cpp::rosbag2_cpp
rosbag2_storage::rosbag2_storage
)
pybind11_add_module(_storage
src/rosbag2_py/_storage.cpp
src/rosbag2_py/format_bag_metadata.cpp
src/rosbag2_py/info_sorting_method.cpp
)
target_link_libraries(_storage PUBLIC
rosbag2_cpp::rosbag2_cpp
rosbag2_storage::rosbag2_storage
)
pybind11_add_module(_writer
src/rosbag2_py/_writer.cpp
)
target_link_libraries(_writer PUBLIC
rosbag2_compression::rosbag2_compression
rosbag2_cpp::rosbag2_cpp
rosbag2_storage::rosbag2_storage
)
pybind11_add_module(_info
src/rosbag2_py/_info.cpp
src/rosbag2_py/format_bag_metadata.cpp
src/rosbag2_py/format_action_info.cpp
src/rosbag2_py/format_service_info.cpp
src/rosbag2_py/format_utils.cpp
src/rosbag2_py/info_sorting_method.cpp
)
target_link_libraries(_info PUBLIC
rosbag2_cpp::rosbag2_cpp
rosbag2_storage::rosbag2_storage
)
pybind11_add_module(_transport
src/rosbag2_py/_transport.cpp
)
target_link_libraries(_transport PUBLIC
rosbag2_compression::rosbag2_compression
rosbag2_cpp::rosbag2_cpp
rosbag2_storage::rosbag2_storage
rosbag2_transport::rosbag2_transport
)
pybind11_add_module(_reindexer
src/rosbag2_py/_reindexer.cpp
)
target_link_libraries(_reindexer PUBLIC
rosbag2_cpp::rosbag2_cpp
rosbag2_storage::rosbag2_storage
)
# Install cython modules as sub-modules of the project
install(
TARGETS
_compression_options
_message_definitions
_reader
_storage
_writer
_info
_transport
_reindexer
DESTINATION "${PYTHON_INSTALL_DIR}/${PROJECT_NAME}"
)
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
find_package(ament_cmake_pytest REQUIRED)
find_package(rosbag2_test_msgdefs REQUIRED)
set(append_env_vars "PYTHONPATH=${CMAKE_CURRENT_SOURCE_DIR}")
set(set_env_vars "ROSBAG2_PY_TEST_RESOURCES_DIR=${CMAKE_CURRENT_SOURCE_DIR}/test/resources")
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# Work around a rtti bug when using class_loader from a
# python extension built with libc++.
list(APPEND set_env_vars "ROSBAG2_PY_TEST_WITH_RTLD_GLOBAL=True")
endif()
ament_add_pytest_test(test_sequential_reader_py
"test/test_sequential_reader.py"
APPEND_ENV "${append_env_vars}"
ENV "${set_env_vars}"
)
ament_add_pytest_test(test_sequential_reader_multiple_files_py
"test/test_sequential_reader_multiple_files.py"
APPEND_ENV "${append_env_vars}"
ENV "${set_env_vars}"
)
ament_add_pytest_test(test_sequential_writer_py
"test/test_sequential_writer.py"
APPEND_ENV "${append_env_vars}"
ENV "${set_env_vars}"
)
ament_add_ros_isolated_pytest_test(test_transport_py
"test/test_transport.py"
APPEND_ENV "${append_env_vars}"
ENV "${set_env_vars}"
)
ament_add_pytest_test(test_reindexer_py
"test/test_reindexer.py"
APPEND_ENV "${append_env_vars}"
ENV "${set_env_vars}"
)
ament_add_pytest_test(test_convert_py
"test/test_convert.py"
APPEND_ENV "${append_env_vars}"
ENV "${set_env_vars}"
)
ament_add_pytest_test(test_compression_py
"test/test_compression.py"
APPEND_ENV "${append_env_vars}"
ENV "${set_env_vars}"
)
ament_add_pytest_test(test_storage_py
"test/test_storage.py"
APPEND_ENV "${append_env_vars}"
ENV "${set_env_vars}"
)
ament_add_pytest_test(test_message_definitions_py
"test/test_message_definitions.py"
APPEND_ENV "${append_env_vars}"
ENV "${set_env_vars}"
)
endif()
ament_package()