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)

View File

@@ -0,0 +1,15 @@
# - Config file for the robot_sbpl package
# It defines the following variables
# robot_sbpl_INCLUDE_DIRS - include directories for robot_sbpl
# robot_sbpl_LIBRARIES - libraries to link against
get_filename_component(robot_sbpl_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set(robot_sbpl_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@")
# Our library dependencies (contains definitions for IMPORTED targets)
if (NOT TARGET robot_sbpl AND NOT robot_sbpl_BINARY_DIR)
include("${robot_sbpl_CMAKE_DIR}/robot_sbpl-targets.cmake")
endif()
# These are IMPORTED targets created by robot_sbpl-targets.cmake
set(robot_sbpl_LIBRARIES robot_sbpl)

View File

@@ -1,20 +1,20 @@
# ===================================================================================
# The SBPL CMake configuration file
# The robot_sbpl CMake configuration file
#
# ** File generated automatically, do not modify **
#
# Usage from an external project:
# In your CMakeLists.txt, add these lines:
#
# FIND_PACKAGE(sbpl REQUIRED )
# INCLUDE_DIRECTORIES(${SBPL_INCLUDE_DIRS})
# TARGET_LINK_LIBRARIES(MY_TARGET_NAME ${SBPL_LIBRARIES})
# FIND_PACKAGE(robot_sbpl REQUIRED )
# INCLUDE_DIRECTORIES(${robot_sbpl_INCLUDE_DIRS})
# TARGET_LINK_LIBRARIES(MY_TARGET_NAME ${robot_sbpl_LIBRARIES})
#
# This file will define the following variables:
# - SBPL_LIBRARIES : The list of libraries to links against as absolute path
# - SBPL_LIBRARY_DIRS : The directory where lib files are. Calling
# - robot_sbpl_LIBRARIES : The list of libraries to links against as absolute path
# - robot_sbpl_LIBRARY_DIRS : The directory where lib files are. Calling
# LINK_DIRECTORIES with this path is NOT needed.
# - SBPL_INCLUDE_DIRS : The SBPL include directories.
# - robot_sbpl_INCLUDE_DIRS : The SBPL include directories.
#
# Based on the example CMake Tutorial
# http://www.vtk.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file
@@ -22,9 +22,9 @@
# ===================================================================================
set(SBPL_INCLUDE_DIRS "@SBPL_INCLUDE_DIR@")
set(SBPL_LIBRARY_DIRS "@SBPL_LIB_DIR@")
set(robot_sbpl_INCLUDE_DIRS "@SBPL_INCLUDE_DIR@")
set(robot_sbpl_LIBRARY_DIRS "@SBPL_LIB_DIR@")
# Set library names as absolute paths:
set(SBPL_LIBRARIES "@SBPL_LIB_DIR@/libsbpl@CMAKE_SHARED_LIBRARY_SUFFIX@")
set(robot_sbpl_LIBRARIES "@SBPL_LIB_DIR@/librobot_sbpl@CMAKE_SHARED_LIBRARY_SUFFIX@")

View File

@@ -1,15 +0,0 @@
# - Config file for the sbpl package
# It defines the following variables
# SBPL_INCLUDE_DIRS - include directories for sbpl
# SBPL_LIBRARIES - libraries to link against
get_filename_component(SBPL_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set(SBPL_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@")
# Our library dependencies (contains definitions for IMPORTED targets)
if (NOT TARGET sbpl AND NOT sbpl_BINARY_DIR)
include("${SBPL_CMAKE_DIR}/sbpl-targets.cmake")
endif()
# These are IMPORTED targets created by sbpl-targets.cmake
set(SBPL_LIBRARIES sbpl)