build: rename the package to robot_sbpl

ros-noetic-sbpl (apt, 2020) installs a libsbpl.so without the abort flag in
/opt/ros/noetic/lib. A ROS environment puts that directory on
LD_LIBRARY_PATH, which the loader searches before any RUNPATH, so a
process that sourced ROS loaded the apt library instead of this one:
sbpl_lattice_planner then ran with a header/library ABI mismatch and
preempt disabled.

The package now follows the robot_* naming of the other packages:
- project and target robot_sbpl, library file librobot_sbpl.so;
- robot_sbpl-config.cmake (installed to share/robot_sbpl/, variables
  robot_sbpl_INCLUDE_DIRS / robot_sbpl_LIBRARIES) and robot_sbpl.pc;
- the target exports src/include as a PUBLIC include directory, so an
  in-tree consumer gets the headers that match the library.
- the target is installed with an export set (robot_sbpl-targets), like
  the other robot_* packages; sbpl_lattice_planner exports its own target
  and CMake requires its shared dependencies to be exported as well.

Headers keep the sbpl/ prefix, so no source include changes.
This commit is contained in:
2026-10-21 14:51:46 +07:00
parent 4eafce2876
commit ce7d0af7d4
6 changed files with 63 additions and 45 deletions

View File

@@ -1,5 +1,10 @@
cmake_minimum_required(VERSION 2.8)
PROJECT( sbpl )
# Package robot_sbpl: the vendored SBPL with the abort flag (cancel/pause cut a running search).
# Named like the other robot_* packages so it cannot collide with ros-noetic-sbpl (apt, 2020): that
# package installs libsbpl.so without the abort flag in /opt/ros/noetic/lib, and a ROS environment
# puts that directory on LD_LIBRARY_PATH, which the loader searches before any RUNPATH. With the
# same file name the apt build silently replaced this one at runtime. Headers keep the sbpl/ prefix.
PROJECT( robot_sbpl )
# version (e.g. for packaging)
set(SBPL_MAJOR_VERSION 1)
@@ -11,7 +16,7 @@ set(CMAKE_BUILD_TYPE Release)
include_directories(src/include)
add_library(sbpl SHARED
add_library(robot_sbpl SHARED
src/discrete_space_information/environment_nav2D.cpp
src/discrete_space_information/environment_navxythetalat.cpp
src/discrete_space_information/environment_navxythetamlevlat.cpp
@@ -34,47 +39,60 @@ add_library(sbpl SHARED
src/utils/config.cpp
)
# Consumers that link the target (an in-tree build) get the headers that match the library.
target_include_directories(robot_sbpl PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/include>
$<INSTALL_INTERFACE:include>)
set(SBPL_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include")
set(SBPL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
# support for pkg-config
set(PKG_NAME "sbpl")
set(PKG_NAME "robot_sbpl")
set(PKG_DESC "The Search Based Planning Library")
set(PKG_SBPL_LIBS "-lsbpl")
set(pkg_conf_file_in "${CMAKE_CURRENT_SOURCE_DIR}/sbpl.pc.in")
set(pkg_conf_file "${PROJECT_BINARY_DIR}/InstallFiles/sbpl.pc")
set(PKG_SBPL_LIBS "-lrobot_sbpl")
set(pkg_conf_file_in "${CMAKE_CURRENT_SOURCE_DIR}/robot_sbpl.pc.in")
set(pkg_conf_file "${PROJECT_BINARY_DIR}/InstallFiles/robot_sbpl.pc")
configure_file("${pkg_conf_file_in}" "${pkg_conf_file}" @ONLY)
install(FILES ${pkg_conf_file} DESTINATION lib/pkgconfig/ COMPONENT pkgconfig)
# support for cmake-config:
configure_file(sbpl-config.cmake.in
"${PROJECT_BINARY_DIR}/InstallFiles/sbpl-config.cmake" @ONLY)
configure_file(sbpl-config-version.cmake.in
"${PROJECT_BINARY_DIR}/InstallFiles/sbpl-config-version.cmake" @ONLY)
configure_file(robot_sbpl-config.cmake.in
"${PROJECT_BINARY_DIR}/InstallFiles/robot_sbpl-config.cmake" @ONLY)
configure_file(robot_sbpl-config-version.cmake.in
"${PROJECT_BINARY_DIR}/InstallFiles/robot_sbpl-config-version.cmake" @ONLY)
install(FILES
"${PROJECT_BINARY_DIR}/InstallFiles/sbpl-config.cmake"
"${PROJECT_BINARY_DIR}/InstallFiles/sbpl-config-version.cmake"
DESTINATION share/sbpl/)
"${PROJECT_BINARY_DIR}/InstallFiles/robot_sbpl-config.cmake"
"${PROJECT_BINARY_DIR}/InstallFiles/robot_sbpl-config-version.cmake"
DESTINATION share/robot_sbpl/)
# support for build tree export
option(SBPL_BUILD_TREE_EXPORT "Enable build tree exports" OFF)
if (${SBPL_BUILD_TREE_EXPORT})
export(TARGETS sbpl FILE sbpl-targets.cmake)
export(TARGETS robot_sbpl FILE robot_sbpl-targets.cmake)
set(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/src/include")
configure_file(
sbpl-config-tree-export.cmake.in
"${PROJECT_BINARY_DIR}/sbpl-config.cmake"
robot_sbpl-config-tree-export.cmake.in
"${PROJECT_BINARY_DIR}/robot_sbpl-config.cmake"
@ONLY)
export(PACKAGE sbpl)
export(PACKAGE robot_sbpl)
endif()
install(DIRECTORY src/include/sbpl DESTINATION include
FILES_MATCHING PATTERN "*.h")
install(TARGETS sbpl
# Exported like the other robot_* packages: a shared library that links robot_sbpl and installs its
# own export set (sbpl_lattice_planner) needs robot_sbpl in an export set too, or CMake fails at
# generate time.
install(TARGETS robot_sbpl
EXPORT robot_sbpl-targets
LIBRARY DESTINATION lib)
install(EXPORT robot_sbpl-targets
FILE robot_sbpl-targets.cmake
NAMESPACE robot_sbpl::
DESTINATION lib/cmake/robot_sbpl)
add_executable(test_sbpl src/test/main.cpp)
target_link_libraries(test_sbpl sbpl)
target_link_libraries(test_sbpl robot_sbpl)
add_executable(test_adjacency_list src/test/test_adjacency_list.cpp)
target_link_libraries(test_adjacency_list sbpl)
target_link_libraries(test_adjacency_list robot_sbpl)