build: doi dependency robot_angles -> robot_angles_prv, don CMake
Package that la robot_angles_prv (package.xml), robot_angles chi la ten thu muc cu - sua build_depend/run_depend va #include cho khop. Gom lai nhanh standalone/catkin trong CMakeLists.txt: dua tf3 find_library ra dung ca 2 nhanh, them install plugins.xml (neu co), FILES_MATCHING "*.h" khi install header, RUNTIME DESTINATION bin cho nhanh standalone.
This commit is contained in:
161
CMakeLists.txt
161
CMakeLists.txt
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0.2)
|
||||
project(robot_base_local_planner VERSION 1.0.0 LANGUAGES CXX)
|
||||
|
||||
# ========================================================
|
||||
# Detect Catkin or Standalone
|
||||
# Detect build mode
|
||||
# ========================================================
|
||||
if(DEFINED CATKIN_DEVEL_PREFIX OR DEFINED CATKIN_TOPLEVEL)
|
||||
set(BUILDING_WITH_CATKIN TRUE)
|
||||
@@ -24,53 +24,15 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
add_compile_options(-Wall -Wextra -Wpedantic)
|
||||
|
||||
# ========================================================
|
||||
# Dependencies
|
||||
# Common dependencies
|
||||
# ========================================================
|
||||
find_package(Boost REQUIRED COMPONENTS thread)
|
||||
find_package(Eigen3 REQUIRED)
|
||||
|
||||
# ========================================================
|
||||
# Catkin configuration
|
||||
# ========================================================
|
||||
if(BUILDING_WITH_CATKIN)
|
||||
|
||||
find_package(catkin REQUIRED COMPONENTS
|
||||
robot_angles
|
||||
robot_costmap_2d
|
||||
robot_std_msgs
|
||||
robot_geometry_msgs
|
||||
robot_sensor_msgs
|
||||
robot_nav_msgs
|
||||
robot_cpp
|
||||
tf3
|
||||
robot_tf3_geometry_msgs
|
||||
robot_voxel_grid
|
||||
data_convert
|
||||
)
|
||||
|
||||
catkin_package(
|
||||
INCLUDE_DIRS include
|
||||
LIBRARIES ${PROJECT_NAME}
|
||||
CATKIN_DEPENDS
|
||||
robot_angles
|
||||
robot_costmap_2d
|
||||
robot_std_msgs
|
||||
robot_geometry_msgs
|
||||
robot_sensor_msgs
|
||||
robot_nav_msgs
|
||||
robot_cpp
|
||||
tf3
|
||||
robot_tf3_geometry_msgs
|
||||
robot_voxel_grid
|
||||
data_convert
|
||||
DEPENDS Boost Eigen3
|
||||
)
|
||||
|
||||
else()
|
||||
|
||||
# ========================================================
|
||||
# Standalone configuration
|
||||
# Standalone mode
|
||||
# ========================================================
|
||||
if(NOT BUILDING_WITH_CATKIN)
|
||||
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
@@ -78,20 +40,79 @@ else()
|
||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
set(CMAKE_BUILD_RPATH "${CMAKE_BINARY_DIR}")
|
||||
|
||||
# ⚠️ placeholder libraries
|
||||
set(PACKAGES_DIR
|
||||
robot_angles
|
||||
robot_angles_prv
|
||||
robot_costmap_2d
|
||||
robot_std_msgs
|
||||
robot_geometry_msgs
|
||||
robot_sensor_msgs
|
||||
robot_nav_msgs
|
||||
robot_cpp
|
||||
tf3
|
||||
robot_tf3_geometry_msgs
|
||||
robot_voxel_grid
|
||||
data_convert
|
||||
)
|
||||
|
||||
find_library(TF3_LIBRARY
|
||||
NAMES tf3
|
||||
PATHS /usr/lib /usr/local/lib /usr/lib/x86_64-linux-gnu
|
||||
)
|
||||
|
||||
if(NOT TF3_LIBRARY)
|
||||
message(FATAL_ERROR "❌ tf3 library not found")
|
||||
endif()
|
||||
|
||||
# ========================================================
|
||||
# Catkin mode
|
||||
# ========================================================
|
||||
else()
|
||||
|
||||
find_package(catkin REQUIRED COMPONENTS
|
||||
robot_angles_prv
|
||||
robot_costmap_2d
|
||||
robot_std_msgs
|
||||
robot_geometry_msgs
|
||||
robot_sensor_msgs
|
||||
robot_nav_msgs
|
||||
robot_cpp
|
||||
robot_tf3_geometry_msgs
|
||||
robot_voxel_grid
|
||||
data_convert
|
||||
)
|
||||
|
||||
find_library(TF3_LIBRARY
|
||||
NAMES tf3
|
||||
PATHS /usr/lib /usr/local/lib /usr/lib/x86_64-linux-gnu
|
||||
)
|
||||
|
||||
if(NOT TF3_LIBRARY)
|
||||
message(FATAL_ERROR "❌ tf3 library not found")
|
||||
endif()
|
||||
|
||||
catkin_package(
|
||||
INCLUDE_DIRS include
|
||||
LIBRARIES ${PROJECT_NAME}
|
||||
CATKIN_DEPENDS
|
||||
robot_angles_prv
|
||||
robot_costmap_2d
|
||||
robot_std_msgs
|
||||
robot_geometry_msgs
|
||||
robot_sensor_msgs
|
||||
robot_nav_msgs
|
||||
robot_cpp
|
||||
robot_tf3_geometry_msgs
|
||||
robot_voxel_grid
|
||||
data_convert
|
||||
DEPENDS Boost Eigen3
|
||||
)
|
||||
|
||||
include_directories(
|
||||
include
|
||||
${catkin_INCLUDE_DIRS}
|
||||
${Boost_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
# ========================================================
|
||||
@@ -129,18 +150,7 @@ add_library(${PROJECT_NAME} SHARED
|
||||
)
|
||||
|
||||
# ========================================================
|
||||
# Include directories
|
||||
# ========================================================
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
|
||||
)
|
||||
|
||||
# ========================================================
|
||||
# Dependencies
|
||||
# Catkin linking
|
||||
# ========================================================
|
||||
if(BUILDING_WITH_CATKIN)
|
||||
|
||||
@@ -148,6 +158,12 @@ if(BUILDING_WITH_CATKIN)
|
||||
${catkin_EXPORTED_TARGETS}
|
||||
)
|
||||
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
|
||||
PUBLIC
|
||||
@@ -156,10 +172,20 @@ if(BUILDING_WITH_CATKIN)
|
||||
PRIVATE
|
||||
Boost::thread
|
||||
Eigen3::Eigen
|
||||
${TF3_LIBRARY}
|
||||
)
|
||||
|
||||
# ========================================================
|
||||
# Standalone linking
|
||||
# ========================================================
|
||||
else()
|
||||
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
|
||||
PUBLIC
|
||||
@@ -168,6 +194,7 @@ else()
|
||||
PRIVATE
|
||||
Boost::thread
|
||||
Eigen3::Eigen
|
||||
${TF3_LIBRARY}
|
||||
)
|
||||
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||
@@ -192,14 +219,22 @@ if(BUILDING_WITH_CATKIN)
|
||||
|
||||
install(DIRECTORY include/${PROJECT_NAME}/
|
||||
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
|
||||
FILES_MATCHING PATTERN "*.h"
|
||||
)
|
||||
|
||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/plugins.xml)
|
||||
install(FILES plugins.xml
|
||||
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
|
||||
)
|
||||
endif()
|
||||
|
||||
else()
|
||||
|
||||
install(TARGETS ${PROJECT_NAME}
|
||||
EXPORT ${PROJECT_NAME}-targets
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib
|
||||
LIBRARY DESTINATION lib
|
||||
RUNTIME DESTINATION bin
|
||||
)
|
||||
|
||||
install(EXPORT ${PROJECT_NAME}-targets
|
||||
@@ -210,13 +245,13 @@ else()
|
||||
|
||||
install(DIRECTORY include/${PROJECT_NAME}/
|
||||
DESTINATION include
|
||||
FILES_MATCHING PATTERN "*.h"
|
||||
)
|
||||
|
||||
message(STATUS "=================================")
|
||||
message(STATUS "Project: ${PROJECT_NAME}")
|
||||
message(STATUS "Version: ${PROJECT_VERSION}")
|
||||
message(STATUS "C++ Standard: ${CMAKE_CXX_STANDARD}")
|
||||
message(STATUS "Libraries: ${PROJECT_NAME}")
|
||||
message(STATUS "=================================")
|
||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/plugins.xml)
|
||||
install(FILES plugins.xml
|
||||
DESTINATION share/${PROJECT_NAME}
|
||||
)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user