Files
sbpl/CMakeLists.txt
duongtd ce7d0af7d4 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.
2026-10-21 15:06:48 +07:00

99 lines
3.8 KiB
CMake

cmake_minimum_required(VERSION 2.8)
# 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)
set(SBPL_MINOR_VERSION 3)
set(SBPL_PATCH_VERSION 1)
set(SBPL_VERSION ${SBPL_MAJOR_VERSION}.${SBPL_MINOR_VERSION}.${SBPL_PATCH_VERSION})
set(CMAKE_BUILD_TYPE Release)
include_directories(src/include)
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
src/discrete_space_information/environment_nav2Duu.cpp
src/discrete_space_information/environment_XXX.cpp
src/discrete_space_information/environment_robarm.cpp
src/heuristics/embedded_heuristic.cpp
src/planners/adplanner.cpp
src/planners/ANAplanner.cpp
src/planners/araplanner.cpp
src/planners/lazyARA.cpp
src/planners/mhaplanner.cpp
src/planners/ppcpplanner.cpp
src/planners/rstarplanner.cpp
src/planners/viplanner.cpp
src/utils/heap.cpp
src/utils/mdp.cpp
src/utils/utils.cpp
src/utils/2Dgridsearch.cpp
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 "robot_sbpl")
set(PKG_DESC "The Search Based Planning Library")
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(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/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 robot_sbpl FILE robot_sbpl-targets.cmake)
set(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/src/include")
configure_file(
robot_sbpl-config-tree-export.cmake.in
"${PROJECT_BINARY_DIR}/robot_sbpl-config.cmake"
@ONLY)
export(PACKAGE robot_sbpl)
endif()
install(DIRECTORY src/include/sbpl DESTINATION include
FILES_MATCHING PATTERN "*.h")
# 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 robot_sbpl)
add_executable(test_adjacency_list src/test/test_adjacency_list.cpp)
target_link_libraries(test_adjacency_list robot_sbpl)