Repository navigation
Expand file tree
/
Copy pathespp.cmake
More file actions
509 lines (487 loc) · 25.1 KB
/
Copy pathespp.cmake
File metadata and controls
509 lines (487 loc) · 25.1 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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
set(ESPP_COMPONENTS "${CMAKE_CURRENT_LIST_DIR}/../components")
# ---------------------------------------------------------------------------
# RTPS static-limits profile selection.
#
# The rtps engine keeps a fully-static (deterministic) allocation model
# whose compile-time capacity caps are chosen by a profile header (see
# components/rtps/include/rtps/config.hpp). Profiles:
# embedded - tight MCU caps (rtps/config_esp32.hpp)
# host - relaxed static caps, DEFAULT for non-ESP builds
# (rtps/config_desktop.hpp)
# host_large - generous static caps for large DDS graphs
# (rtps/config_host_large.hpp)
#
# Select with -DRTPS_LIMITS_PROFILE=embedded|host|host_large. Default is "host"
# (this file is only used for non-ESP / host builds; ESP/IDF builds pick the
# profile via Kconfig in components/rtps/Kconfig).
# ---------------------------------------------------------------------------
if(NOT DEFINED RTPS_LIMITS_PROFILE)
set(RTPS_LIMITS_PROFILE "host")
endif()
set(RTPS_LIMITS_PROFILE "${RTPS_LIMITS_PROFILE}" CACHE STRING
"RTPS static limits profile: embedded|host|host_large")
set_property(CACHE RTPS_LIMITS_PROFILE PROPERTY STRINGS embedded host host_large)
if(RTPS_LIMITS_PROFILE STREQUAL "embedded")
set(RTPS_CONFIG_HEADER_FILE "rtps/config_esp32.hpp")
set(RTPS_MAX_SAMPLE_SIZE 262144) # 256 KB (matches config_esp32.hpp)
elseif(RTPS_LIMITS_PROFILE STREQUAL "host")
set(RTPS_CONFIG_HEADER_FILE "rtps/config_desktop.hpp")
set(RTPS_MAX_SAMPLE_SIZE 8388608) # 8 MB (matches config_desktop.hpp)
elseif(RTPS_LIMITS_PROFILE STREQUAL "host_large")
set(RTPS_CONFIG_HEADER_FILE "rtps/config_host_large.hpp")
set(RTPS_MAX_SAMPLE_SIZE 8388608) # 8 MB (matches config_host_large.hpp)
else()
message(FATAL_ERROR
"Invalid RTPS_LIMITS_PROFILE '${RTPS_LIMITS_PROFILE}' "
"(expected: embedded | host | host_large)")
endif()
add_compile_definitions(RTPS_CONFIG_HEADER="${RTPS_CONFIG_HEADER_FILE}")
message(STATUS "RTPS limits profile: ${RTPS_LIMITS_PROFILE}")
# ---------------------------------------------------------------------------
# RTPS per-constant overrides (fine-grained alternative to switching
# profiles): a semicolon list of NAME=VALUE entries, each overriding ONE
# constant of the selected profile via its RTPS_CFG_<NAME> macro - the
# capacity caps, the discovery/reliability timing, the task priorities and
# stacks, and the domain id - e.g.
# -DRTPS_LIMIT_OVERRIDES="NUM_STATELESS_WRITERS=16;HISTORY_SIZE_STATEFUL=20;DOMAIN_ID=3"
# See the RTPS_CFG_* blocks in include/rtps/config_*.hpp for the knob names
# (the ESP-IDF build exposes the same knobs through menuconfig).
# Applied as GLOBAL compile definitions so the engine sources (which size the
# pools) and every consumer translation unit agree on the values - defining
# them for only a consumer TU would silently disagree with the library.
# None of them changes the wire format: the capacity caps only size pools, the
# timing knobs only change WHEN discovery/reliability messages are sent, the
# task knobs how the engine's tasks are scheduled, and the domain id selects
# the UDP port base (7400 + 250 * id) and GUID prefix byte 9.
# ---------------------------------------------------------------------------
set(RTPS_LIMIT_OVERRIDES "" CACHE STRING
"Semicolon list of RTPS config overrides, e.g. NUM_STATELESS_WRITERS=16;HISTORY_SIZE_STATEFUL=20;DOMAIN_ID=3")
# The supported knobs (must match the RTPS_CFG_* blocks in the profile headers).
# Validated: an unknown name would silently define an unused macro (no override
# at all), and an out-of-range value would silently truncate - e.g. 256 into a
# uint8_t knob becomes a ZERO-capacity pool. Most knobs back uint8_t constants
# (range 1..255); the unmatched-remote registries and the SPDP participant pool
# are uint16_t in the host profiles (host_large defaults them to 1024/512/128),
# so those three accept up to 65535 - EXCEPT under the embedded profile, where
# they are uint8_t too.
set(RTPS_LIMIT_KNOB_NAMES
NUM_STATELESS_WRITERS NUM_STATELESS_READERS NUM_STATEFUL_WRITERS NUM_STATEFUL_READERS
MAX_NUM_PARTICIPANTS NUM_WRITERS_PER_PARTICIPANT NUM_READERS_PER_PARTICIPANT
NUM_WRITER_PROXIES_PER_READER NUM_READER_PROXIES_PER_WRITER
MAX_NUM_UNMATCHED_REMOTE_WRITERS MAX_NUM_UNMATCHED_REMOTE_READERS
MAX_NUM_READER_CALLBACKS HISTORY_SIZE_STATELESS HISTORY_SIZE_STATEFUL
MAX_TYPENAME_LENGTH MAX_TOPICNAME_LENGTH MAX_NUM_UDP_CONNECTIONS
SPDP_MAX_NUMBER_FOUND_PARTICIPANTS SPDP_MAX_NUM_LOCATORS
# tuning (not capacity): timing, tasks, domain id - same macro mechanism
SPDP_RESEND_PERIOD_MS SPDP_CYCLECOUNT_HEARTBEAT SF_WRITER_HB_PERIOD_MS
SPDP_DEFAULT_REMOTE_LEASE_DURATION_S SPDP_MAX_REMOTE_LEASE_DURATION_S
THREAD_POOL_READER_PRIO THREAD_POOL_READER_STACKSIZE SPDP_WRITER_PRIO SPDP_WRITER_STACKSIZE
DOMAIN_ID)
set(RTPS_LIMIT_UINT16_KNOBS MAX_NUM_UNMATCHED_REMOTE_WRITERS MAX_NUM_UNMATCHED_REMOTE_READERS
SPDP_MAX_NUMBER_FOUND_PARTICIPANTS)
# Knobs that are uint16_t on EVERY profile (the two above are uint8_t under the
# embedded profile), int-typed stacks, the Duration_t seconds, and the domain id
# (uint8_t, 0..232 by the DDS port formula) have their own ranges.
set(RTPS_LIMIT_UINT16_ALL_KNOBS SPDP_RESEND_PERIOD_MS SF_WRITER_HB_PERIOD_MS SPDP_WRITER_STACKSIZE)
set(RTPS_LIMIT_INT_KNOBS THREAD_POOL_READER_STACKSIZE)
set(RTPS_LIMIT_SECONDS_KNOBS SPDP_DEFAULT_REMOTE_LEASE_DURATION_S SPDP_MAX_REMOTE_LEASE_DURATION_S)
# Collect the validated definitions; they are applied directory-wide below AND
# exported via ESPP_RTPS_COMPILE_DEFINITIONS (they change public Config
# constants and array-backed layouts, so a find_package(espp) consumer MUST
# compile the headers with the same values the archive was built with).
set(RTPS_LIMIT_OVERRIDE_DEFS "")
foreach(override ${RTPS_LIMIT_OVERRIDES})
if(NOT override MATCHES "^([A-Z_]+)=([0-9]+)$")
message(FATAL_ERROR "Invalid RTPS_LIMIT_OVERRIDES entry '${override}' (expected NAME=VALUE)")
endif()
string(REGEX REPLACE "^([A-Z_]+)=[0-9]+$" "\\1" _rtps_knob "${override}")
string(REGEX REPLACE "^[A-Z_]+=([0-9]+)$" "\\1" _rtps_value "${override}")
if(NOT _rtps_knob IN_LIST RTPS_LIMIT_KNOB_NAMES)
message(FATAL_ERROR
"Unknown RTPS limit knob '${_rtps_knob}' in RTPS_LIMIT_OVERRIDES. Supported knobs: "
"${RTPS_LIMIT_KNOB_NAMES}")
endif()
if(_rtps_knob IN_LIST RTPS_LIMIT_UINT16_KNOBS AND NOT RTPS_LIMITS_PROFILE STREQUAL "embedded")
set(_rtps_max 65535)
set(_rtps_type "uint16_t")
elseif(_rtps_knob IN_LIST RTPS_LIMIT_UINT16_ALL_KNOBS)
set(_rtps_max 65535)
set(_rtps_type "uint16_t")
elseif(_rtps_knob IN_LIST RTPS_LIMIT_INT_KNOBS)
set(_rtps_max 1048576)
set(_rtps_type "int")
elseif(_rtps_knob IN_LIST RTPS_LIMIT_SECONDS_KNOBS)
set(_rtps_max 3600)
set(_rtps_type "Duration_t seconds")
elseif(_rtps_knob STREQUAL "DOMAIN_ID")
set(_rtps_max 232)
set(_rtps_type "uint8_t domain id")
else()
set(_rtps_max 255)
set(_rtps_type "uint8_t")
endif()
# Builtin-aware minima: the discovery endpoints draw from these pools, so a
# technically-representable value below the reservation would crash startup
# (the second SEDP allocation returns null and createBuiltinWritersAndReaders
# dereferences it) or silently omit the builtins (per-participant caps < 3).
if(_rtps_knob STREQUAL "NUM_STATEFUL_WRITERS" OR _rtps_knob STREQUAL "NUM_STATEFUL_READERS")
set(_rtps_min 2) # 2 SEDP builtins
elseif(_rtps_knob STREQUAL "NUM_WRITERS_PER_PARTICIPANT"
OR _rtps_knob STREQUAL "NUM_READERS_PER_PARTICIPANT")
set(_rtps_min 3) # SPDP + 2 SEDP builtins
elseif(_rtps_knob STREQUAL "MAX_NUM_UDP_CONNECTIONS")
set(_rtps_min 4) # 2 shared multicast + 2 unicast channels for 1 participant
elseif(_rtps_knob STREQUAL "THREAD_POOL_READER_STACKSIZE" OR _rtps_knob STREQUAL "SPDP_WRITER_STACKSIZE")
# On a host build these are not applied at all (espp::Task only sets task
# stacks on ESP through esp_pthread; std::thread uses the platform default),
# so only the type is range-checked here. The 2048-byte FreeRTOS minimum is
# enforced by the ESP-IDF component build (components/rtps/CMakeLists.txt),
# where it is real; the host profiles' own defaults (1600 / 550) must stay
# expressible as overrides.
set(_rtps_min 1)
elseif(_rtps_knob STREQUAL "DOMAIN_ID")
set(_rtps_min 0) # 0 is the DDS default domain, a real value
else()
set(_rtps_min 1)
endif()
if(_rtps_value LESS ${_rtps_min} OR _rtps_value GREATER ${_rtps_max})
message(FATAL_ERROR
"RTPS limit override '${override}' out of range: ${_rtps_knob} is ${_rtps_type} under the "
"'${RTPS_LIMITS_PROFILE}' profile, valid range ${_rtps_min}..${_rtps_max} (minima account "
"for the builtin discovery endpoints)")
endif()
add_compile_definitions("RTPS_CFG_${override}")
list(APPEND RTPS_LIMIT_OVERRIDE_DEFS "RTPS_CFG_${override}")
set(RTPS_EFFECTIVE_${_rtps_knob} ${_rtps_value})
message(STATUS "RTPS limit override: ${override}")
endforeach()
# Cross-limit capacity check: the endpoint pools are GLOBAL, and EVERY
# participant consumes 1 stateless writer/reader + 2 stateful writers/readers
# for its builtin discovery endpoints - per-knob minima alone cannot see a
# combination like NUM_STATEFUL_WRITERS=2 with MAX_NUM_PARTICIPANTS=8, whose
# second participant would exhaust the pool (the engine now fails that
# participant cleanly, but a documented override should not configure a
# participant budget it cannot deliver). Effective value = override if given,
# else the selected profile's default.
if(RTPS_LIMITS_PROFILE STREQUAL "embedded")
set(_rtps_d_participants 1)
set(_rtps_d_stateless_w 5)
set(_rtps_d_stateless_r 5)
set(_rtps_d_stateful_w 5)
set(_rtps_d_stateful_r 5)
set(_rtps_d_channels 10)
elseif(RTPS_LIMITS_PROFILE STREQUAL "host")
set(_rtps_d_participants 8)
set(_rtps_d_stateless_w 16)
set(_rtps_d_stateless_r 16)
set(_rtps_d_stateful_w 32)
set(_rtps_d_stateful_r 32)
set(_rtps_d_channels 24)
else() # host_large
set(_rtps_d_participants 32)
set(_rtps_d_stateless_w 64)
set(_rtps_d_stateless_r 64)
set(_rtps_d_stateful_w 128)
set(_rtps_d_stateful_r 128)
set(_rtps_d_channels 72)
endif()
foreach(pair
"MAX_NUM_PARTICIPANTS;_rtps_d_participants"
"NUM_STATELESS_WRITERS;_rtps_d_stateless_w"
"NUM_STATELESS_READERS;_rtps_d_stateless_r"
"NUM_STATEFUL_WRITERS;_rtps_d_stateful_w"
"NUM_STATEFUL_READERS;_rtps_d_stateful_r"
"MAX_NUM_UDP_CONNECTIONS;_rtps_d_channels")
list(GET pair 0 _rtps_k)
list(GET pair 1 _rtps_dvar)
if(NOT DEFINED RTPS_EFFECTIVE_${_rtps_k})
set(RTPS_EFFECTIVE_${_rtps_k} ${${_rtps_dvar}})
endif()
endforeach()
math(EXPR _rtps_need_stateful "2 * ${RTPS_EFFECTIVE_MAX_NUM_PARTICIPANTS}")
if(RTPS_EFFECTIVE_NUM_STATELESS_WRITERS LESS RTPS_EFFECTIVE_MAX_NUM_PARTICIPANTS
OR RTPS_EFFECTIVE_NUM_STATELESS_READERS LESS RTPS_EFFECTIVE_MAX_NUM_PARTICIPANTS
OR RTPS_EFFECTIVE_NUM_STATEFUL_WRITERS LESS _rtps_need_stateful
OR RTPS_EFFECTIVE_NUM_STATEFUL_READERS LESS _rtps_need_stateful)
message(FATAL_ERROR
"RTPS limits cannot host the participant budget: MAX_NUM_PARTICIPANTS="
"${RTPS_EFFECTIVE_MAX_NUM_PARTICIPANTS} needs >= ${RTPS_EFFECTIVE_MAX_NUM_PARTICIPANTS} "
"stateless writers/readers (have ${RTPS_EFFECTIVE_NUM_STATELESS_WRITERS}/"
"${RTPS_EFFECTIVE_NUM_STATELESS_READERS}) and >= ${_rtps_need_stateful} stateful "
"writers/readers (have ${RTPS_EFFECTIVE_NUM_STATEFUL_WRITERS}/"
"${RTPS_EFFECTIVE_NUM_STATEFUL_READERS}) for the builtin discovery endpoints. Raise the "
"pool overrides or lower MAX_NUM_PARTICIPANTS.")
endif()
# Channel-pool constraint: a Domain permanently binds 2 shared multicast
# channels (SPDP metatraffic + user multicast) and 2 unicast channels per
# participant (builtin + user), all drawn from the same
# MAX_NUM_UDP_CONNECTIONS transport pool as runtime dedicated endpoint ports.
# Without this check an override combination can pass the endpoint-pool math
# above yet createParticipant() still fails on channels before reaching the
# advertised participant capacity.
math(EXPR _rtps_need_channels "2 + 2 * ${RTPS_EFFECTIVE_MAX_NUM_PARTICIPANTS}")
if(RTPS_EFFECTIVE_MAX_NUM_UDP_CONNECTIONS LESS _rtps_need_channels)
message(FATAL_ERROR
"RTPS limits cannot host the participant budget: MAX_NUM_PARTICIPANTS="
"${RTPS_EFFECTIVE_MAX_NUM_PARTICIPANTS} needs >= ${_rtps_need_channels} transport channels "
"(2 shared multicast + 2 unicast per participant) but MAX_NUM_UDP_CONNECTIONS is "
"${RTPS_EFFECTIVE_MAX_NUM_UDP_CONNECTIONS}. Raise MAX_NUM_UDP_CONNECTIONS (leave headroom "
"for dedicated endpoint ports - max_prioritized_endpoint_ports, default 4 - which draw "
"from the same pool at runtime) or lower MAX_NUM_PARTICIPANTS.")
endif()
# ---------------------------------------------------------------------------
# RTPS best-effort DATA_FRAG fragmentation (Slice C).
#
# On host builds fragmentation is ALWAYS enabled: samples larger than a single
# DATA submessage are split into DATA_FRAG submessages and reassembled by the
# peer (interoperates with FastDDS / ROS 2). RTPS_MAX_SAMPLE_SIZE is the
# large-sample reassembly cap and is kept in sync with the profile's
# Config::MAX_SAMPLE_SIZE. On ESP32/IDF fragmentation is opt-in via Kconfig (see
# components/rtps/Kconfig / CMakeLists.txt), default off, so the MCU
# pays nothing for it by default.
# ---------------------------------------------------------------------------
add_compile_definitions(RTPS_ENABLE_FRAGMENTATION RTPS_MAX_SAMPLE_SIZE=${RTPS_MAX_SAMPLE_SIZE})
message(STATUS "RTPS fragmentation: ON (max sample size ${RTPS_MAX_SAMPLE_SIZE} bytes)")
# The RTPS static-limits + fragmentation config is compiled into libespp_pc.a AND
# is part of the public ABI: any consumer that compiles rtps headers (templates /
# inline code) must use the SAME profile, else it sees a different Config and a
# different set of guarded declarations (e.g. addSubMessageDataFrag). Expose them
# as PUBLIC compile definitions on the exported target (see lib/CMakeLists.txt) so
# find_package(espp) consumers inherit them automatically. The above
# add_compile_definitions still covers the in-tree python module / SKBUILD build.
set(ESPP_RTPS_COMPILE_DEFINITIONS
RTPS_CONFIG_HEADER="${RTPS_CONFIG_HEADER_FILE}"
RTPS_ENABLE_FRAGMENTATION
RTPS_MAX_SAMPLE_SIZE=${RTPS_MAX_SAMPLE_SIZE}
# Per-limit overrides are ABI-critical for the same reason as the profile
# header: they resize public Config constants and the array-backed pools, so
# exported consumers must see identical values (empty when no overrides).
${RTPS_LIMIT_OVERRIDE_DEFS})
set(ESPP_EXTERNAL_INCLUDES
${ESPP_COMPONENTS}/serialization/detail/alpaca/include
${ESPP_COMPONENTS}/cli/detail/cli/include
${ESPP_COMPONENTS}/csv/detail/csv2/include
${ESPP_COMPONENTS}/format/detail/fmt/include
${ESPP_COMPONENTS}/tabulate/detail/tabulate/include
)
# NOTE: these are separate because they do not follow the standard format of
# having their include files be in the "include" directory, so when we install
# them we need to handle them separately
set(ESPP_EXTERNAL_INCLUDES_SEPARATE
${ESPP_COMPONENTS}/hid-rp/detail/hid-rp/hid-rp/
${ESPP_COMPONENTS}/state_machine/detail/magic_enum/include/magic_enum/
)
set(ESPP_INCLUDES
${ESPP_COMPONENTS}/base_component/include
${ESPP_COMPONENTS}/base_peripheral/include
${ESPP_COMPONENTS}/cdr/include
${ESPP_COMPONENTS}/cdr/detail/cdr/include
${ESPP_COMPONENTS}/reflect_cpp/detail/reflect-cpp/include
${ESPP_COMPONENTS}/cobs/include
${ESPP_COMPONENTS}/color/include
${ESPP_COMPONENTS}/csv/include
${ESPP_COMPONENTS}/dispatcher/include
${ESPP_COMPONENTS}/event_manager/include
${ESPP_COMPONENTS}/file_system/include
${ESPP_COMPONENTS}/filters/include
${ESPP_COMPONENTS}/ftp/include
${ESPP_COMPONENTS}/format/include
${ESPP_COMPONENTS}/hid-rp/include
${ESPP_COMPONENTS}/joystick/include
${ESPP_COMPONENTS}/logger/include
${ESPP_COMPONENTS}/math/include
${ESPP_COMPONENTS}/ndef/include
${ESPP_COMPONENTS}/odrive_native/include
${ESPP_COMPONENTS}/persistent_data/include
${ESPP_COMPONENTS}/pid/include
${ESPP_COMPONENTS}/rtps/include
${ESPP_COMPONENTS}/rtsp/include
${ESPP_COMPONENTS}/serialization/include
${ESPP_COMPONENTS}/tabulate/include
${ESPP_COMPONENTS}/task/include
${ESPP_COMPONENTS}/thread_pool/include
${ESPP_COMPONENTS}/timer/include
${ESPP_COMPONENTS}/trajectory_planner/include
${ESPP_COMPONENTS}/socket/include
${ESPP_COMPONENTS}/state_machine/include
${ESPP_COMPONENTS}/stream_frame/include
${ESPP_COMPONENTS}/wdi/include
${CMAKE_CURRENT_LIST_DIR}/include
)
set(ESPP_SOURCES
${ESPP_COMPONENTS}/cobs/src/cobs.cpp
${ESPP_COMPONENTS}/cobs/src/cobs_stream.cpp
${ESPP_COMPONENTS}/color/src/color.cpp
${ESPP_COMPONENTS}/event_manager/src/event_manager.cpp
${ESPP_COMPONENTS}/logger/src/logger.cpp
${ESPP_COMPONENTS}/file_system/src/file_system.cpp
${ESPP_COMPONENTS}/filters/src/lowpass_filter.cpp
${ESPP_COMPONENTS}/filters/src/simple_lowpass_filter.cpp
${ESPP_COMPONENTS}/joystick/src/joystick.cpp
${ESPP_COMPONENTS}/rtps/src/rtps_participant.cpp
${ESPP_COMPONENTS}/rtps/src/communication/EsppTransport.cpp
${ESPP_COMPONENTS}/rtps/src/discovery/ParticipantProxyData.cpp
${ESPP_COMPONENTS}/rtps/src/discovery/SEDPAgent.cpp
${ESPP_COMPONENTS}/rtps/src/discovery/SPDPAgent.cpp
${ESPP_COMPONENTS}/rtps/src/discovery/TopicData.cpp
${ESPP_COMPONENTS}/rtps/src/entities/Domain.cpp
${ESPP_COMPONENTS}/rtps/src/entities/Participant.cpp
${ESPP_COMPONENTS}/rtps/src/entities/Reader.cpp
${ESPP_COMPONENTS}/rtps/src/entities/StatefulReader.cpp
${ESPP_COMPONENTS}/rtps/src/entities/StatefulWriter.cpp
${ESPP_COMPONENTS}/rtps/src/entities/StatelessReader.cpp
${ESPP_COMPONENTS}/rtps/src/entities/StatelessWriter.cpp
${ESPP_COMPONENTS}/rtps/src/entities/Writer.cpp
${ESPP_COMPONENTS}/rtps/src/messages/MessageReceiver.cpp
${ESPP_COMPONENTS}/rtps/src/messages/MessageTypes.cpp
${ESPP_COMPONENTS}/rtps/src/utils/Diagnostics.cpp
${ESPP_COMPONENTS}/rtsp/src/rtcp_packet.cpp
${ESPP_COMPONENTS}/rtsp/src/rtp_packet.cpp
${ESPP_COMPONENTS}/rtsp/src/rtsp_client.cpp
${ESPP_COMPONENTS}/rtsp/src/rtsp_server.cpp
${ESPP_COMPONENTS}/rtsp/src/rtsp_session.cpp
${ESPP_COMPONENTS}/rtsp/src/generic_depacketizer.cpp
${ESPP_COMPONENTS}/rtsp/src/generic_packetizer.cpp
${ESPP_COMPONENTS}/rtsp/src/h264_packetizer.cpp
${ESPP_COMPONENTS}/rtsp/src/h264_depacketizer.cpp
${ESPP_COMPONENTS}/rtsp/src/mjpeg_depacketizer.cpp
${ESPP_COMPONENTS}/rtsp/src/mjpeg_packetizer.cpp
${ESPP_COMPONENTS}/task/src/task.cpp
${ESPP_COMPONENTS}/thread_pool/src/thread_pool.cpp
${ESPP_COMPONENTS}/timer/src/timer.cpp
${ESPP_COMPONENTS}/trajectory_planner/src/trajectory_planner.cpp
${ESPP_COMPONENTS}/socket/src/socket.cpp
${ESPP_COMPONENTS}/socket/src/tcp_socket.cpp
${ESPP_COMPONENTS}/socket/src/udp_socket.cpp
${ESPP_COMPONENTS}/socket/src/socket_reactor.cpp
${CMAKE_CURRENT_LIST_DIR}/espp.cpp
)
set(ESPP_INCLUDE_DIRS
${ESPP_INCLUDES}
${ESPP_EXTERNAL_INCLUDES}
${ESPP_EXTERNAL_INCLUDES_SEPARATE}
)
# if we're on windows, we need to add wcswidth.c to the sources
if(MSVC)
list(APPEND ESPP_SOURCES ${CMAKE_CURRENT_LIST_DIR}/wcswidth.c)
endif()
# On Windows link against ws2_32 (sockets), winmm (timeBeginPeriod, used by the
# TimerResolution helper in espp.hpp), and iphlpapi (GetAdaptersAddresses, used
# by RtpsParticipant interface auto-detection). Centralizing these here keeps
# linkage consistent across the static library, tests, and the _espp module, and
# works on all Windows toolchains (MSVC, MinGW, clang) rather than relying on
# MSVC-only #pragma comment(lib, ...).
if(WIN32)
set(ESPP_EXTERNAL_LIBS ws2_32 winmm iphlpapi)
else()
set(ESPP_EXTERNAL_LIBS pthread)
endif()
set(ESPP_PYTHON_BINDINGS_DIR ${CMAKE_CURRENT_LIST_DIR}/python_bindings)
set(ESPP_PYTHON_SOURCES
${ESPP_PYTHON_BINDINGS_DIR}/module.cpp
${ESPP_PYTHON_BINDINGS_DIR}/pybind_espp.cpp
${ESPP_PYTHON_BINDINGS_DIR}/dispatcher_bindings.cpp
${ESPP_PYTHON_BINDINGS_DIR}/odrive_native_bindings.cpp
${ESPP_PYTHON_BINDINGS_DIR}/rtps_bindings.cpp
${ESPP_PYTHON_BINDINGS_DIR}/socket_reactor_bindings.cpp
${ESPP_PYTHON_BINDINGS_DIR}/wdi_bindings.cpp
${ESPP_SOURCES}
)
# make an espp_install_cmake_package command that gives the C++ library target a
# proper install + export so a separate project can `find_package(espp)` and link
# `espp::espp`. Installs into GNUInstallDirs under CMAKE_INSTALL_PREFIX:
# <prefix>/lib/libespp_pc.a
# <prefix>/include/... (all component + vendored headers, flat)
# <prefix>/lib/cmake/espp/esppTargets.cmake, esppConfig.cmake, ...Version.cmake
#
# All third-party deps (reflect-cpp, magic_enum, tabulate, fmt, alpaca, cli,
# csv2, hid-rp, cdr) are VENDORED: their headers are installed under
# <prefix>/include and their objects are compiled into libespp_pc.a, so a
# consumer needs no extra find_package for them. The only non-bundled PUBLIC
# dependency is the system threads library (handled via find_dependency(Threads)
# in esppConfig.cmake.in; on Windows the ws2_32/winmm/iphlpapi system libs
# resolve automatically).
function(espp_install_cmake_package TARGET_NAME)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
install(TARGETS ${TARGET_NAME}
EXPORT esppTargets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# Install the public headers flat into <prefix>/include so every quote-include
# espp uses resolves against a single -I<prefix>/include. All three lists are
# already on the build include path, and their headers are referenced flat
# relative to those roots, so installing each dir's CONTENTS (the trailing
# slash) yields the exact layout consumers compile against:
# - ESPP_INCLUDES / ESPP_EXTERNAL_INCLUDES: ".../include" dirs -> "logger.hpp".
# - ESPP_EXTERNAL_INCLUDES_SEPARATE: dirs NOT named "include" but still on the
# -I path, referenced flat -> "magic_enum.hpp", "hid/...", "sized_unsigned.hpp".
# This intentionally differs from the old lib/pc helper (which preserved the
# SEPARATE dir names under include/): that only worked because the pc build also
# had the source dirs on its -I path; a pure find_package consumer needs flat.
# Verified by building a find_package consumer that includes both a regular and
# a SEPARATE header.
foreach(_inc IN LISTS ESPP_INCLUDES ESPP_EXTERNAL_INCLUDES ESPP_EXTERNAL_INCLUDES_SEPARATE)
install(DIRECTORY ${_inc}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
endforeach()
install(EXPORT esppTargets
NAMESPACE espp::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/espp
FILE esppTargets.cmake)
configure_package_config_file(
${CMAKE_CURRENT_LIST_DIR}/cmake/esppConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/esppConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/espp)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/esppConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/esppConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/esppConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/espp)
endfunction()
# make an espp_add_python_module command that defines the `_espp` pybind11
# extension module target (the native part of the `espp` python package)
function(espp_add_python_module)
pybind11_add_module(_espp ${ESPP_PYTHON_SOURCES})
target_compile_features(_espp PRIVATE cxx_std_23)
# disable certain compiler warnings for this module, but only if we're not on
# Windows
if(NOT MSVC)
target_compile_options(_espp PRIVATE -Wno-braced-scalar-init -Wno-unused-variable -Wno-unused-parameter)
endif()
target_link_libraries(_espp PRIVATE ${ESPP_EXTERNAL_LIBS})
# embed the package version (set by scikit-build-core when building wheels);
# prefer the full PEP 440 version (includes .devN+local parts) over the
# CMake-compatible X.Y.Z truncation
if(DEFINED SKBUILD_PROJECT_VERSION_FULL)
target_compile_definitions(_espp PRIVATE VERSION_INFO=${SKBUILD_PROJECT_VERSION_FULL})
elseif(DEFINED SKBUILD_PROJECT_VERSION)
target_compile_definitions(_espp PRIVATE VERSION_INFO=${SKBUILD_PROJECT_VERSION})
endif()
endfunction()
# make an espp_install_python_module command that installs the full `espp` python
# package (pure-python files + the compiled `_espp` extension) into the standard
# install prefix as <prefix>/espp, so CMAKE_INSTALL_PREFIX can be put on sys.path
# / PYTHONPATH to `import espp`. Relative DESTINATIONs are interpreted against
# CMAKE_INSTALL_PREFIX.
function(espp_install_python_module)
espp_add_python_module()
install(DIRECTORY ${ESPP_PYTHON_BINDINGS_DIR}/espp
DESTINATION .
PATTERN "__pycache__" EXCLUDE
PATTERN ".mypy_cache" EXCLUDE)
# Also stage espp_odrive (the pure-python ODrive client that lives in the
# odrive_native component) next to the espp package, mirroring the wheel's
# `wheel.packages` in pyproject.toml -- so PYTHONPATH=<prefix> gives both
# `import espp` and `import espp_odrive` (and espp.odrive works).
install(DIRECTORY ${ESPP_COMPONENTS}/odrive_native/python/espp_odrive
DESTINATION .
PATTERN "__pycache__" EXCLUDE)
install(TARGETS _espp
LIBRARY DESTINATION espp/
RUNTIME DESTINATION espp/)
endfunction()