build: vendor the Slamtec rplidar SDK in third_party

The repo is now self-contained: driver_rplidar compiles the SDK from
third_party/rplidar_sdk (Linux sources only, teardown delete[] bug fixed
in place), so a plain cmake configure needs no SDK path and no probing —
the XLIDAR_RPLIDAR_SDK_DIR option and external references are gone.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-15 09:15:37 +07:00
parent ef217bdca8
commit 161a33a71e
58 changed files with 10690 additions and 45 deletions

View File

@@ -1,35 +1,12 @@
# The rplidar plugin compiles the vendor SDK straight into the plugin .so.
# XLIDAR_RPLIDAR_SDK_DIR must point at a directory holding include/ + src/;
# when unset, common local layouts are probed. Without an SDK the plugin is
# skipped (the rest of the build is unaffected).
if(NOT XLIDAR_RPLIDAR_SDK_DIR)
foreach(candidate
${CMAKE_SOURCE_DIR}/third_party/rplidar_sdk
${CMAKE_SOURCE_DIR}/../rplidar_sdk/sdk
${CMAKE_SOURCE_DIR}/../xloc-monorepo/xlocd/deps/rplidar_sdk)
if(EXISTS ${candidate}/include/sl_lidar.h)
set(XLIDAR_RPLIDAR_SDK_DIR ${candidate})
break()
endif()
endforeach()
endif()
if(NOT XLIDAR_RPLIDAR_SDK_DIR OR NOT EXISTS ${XLIDAR_RPLIDAR_SDK_DIR}/include/sl_lidar.h)
message(WARNING "driver_rplidar: Slamtec SDK not found "
"(set -DXLIDAR_RPLIDAR_SDK_DIR=...) — plugin skipped")
return()
endif()
message(STATUS "driver_rplidar: using SDK at ${XLIDAR_RPLIDAR_SDK_DIR}")
# Compiles the vendored Slamtec SDK (third_party/rplidar_sdk) straight into
# the plugin .so — no external dependency.
set(RPLIDAR_SDK_DIR ${CMAKE_SOURCE_DIR}/third_party/rplidar_sdk)
file(GLOB_RECURSE RPLIDAR_SDK_SOURCES CONFIGURE_DEPENDS
${XLIDAR_RPLIDAR_SDK_DIR}/src/*.cpp)
# The SDK ships win32/macOS arch files; keep Linux only.
list(FILTER RPLIDAR_SDK_SOURCES EXCLUDE REGEX "arch/(win32|macOS)/")
${RPLIDAR_SDK_DIR}/src/*.cpp)
xlidar_add_plugin(driver_rplidar rplidar_driver.cpp ${RPLIDAR_SDK_SOURCES})
target_include_directories(driver_rplidar SYSTEM PRIVATE
${XLIDAR_RPLIDAR_SDK_DIR}/include
${XLIDAR_RPLIDAR_SDK_DIR}/src
${RPLIDAR_SDK_DIR}/include
${RPLIDAR_SDK_DIR}/src
)