diff --git a/CMakeLists.txt b/CMakeLists.txt index 99723df..971984e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 + $ + $) + 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) diff --git a/robot_sbpl-config-tree-export.cmake.in b/robot_sbpl-config-tree-export.cmake.in new file mode 100644 index 0000000..fd170a8 --- /dev/null +++ b/robot_sbpl-config-tree-export.cmake.in @@ -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) diff --git a/sbpl-config-version.cmake.in b/robot_sbpl-config-version.cmake.in similarity index 100% rename from sbpl-config-version.cmake.in rename to robot_sbpl-config-version.cmake.in diff --git a/sbpl-config.cmake.in b/robot_sbpl-config.cmake.in similarity index 51% rename from sbpl-config.cmake.in rename to robot_sbpl-config.cmake.in index 69d8fd4..b1f7706 100644 --- a/sbpl-config.cmake.in +++ b/robot_sbpl-config.cmake.in @@ -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@") \ No newline at end of file +set(robot_sbpl_LIBRARIES "@SBPL_LIB_DIR@/librobot_sbpl@CMAKE_SHARED_LIBRARY_SUFFIX@") diff --git a/sbpl.pc.in b/robot_sbpl.pc.in similarity index 100% rename from sbpl.pc.in rename to robot_sbpl.pc.in diff --git a/sbpl-config-tree-export.cmake.in b/sbpl-config-tree-export.cmake.in deleted file mode 100644 index ec1b2d8..0000000 --- a/sbpl-config-tree-export.cmake.in +++ /dev/null @@ -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)