This commit is contained in:
HiepLM 2025-12-29 17:10:32 +07:00
parent a09cd3d98b
commit cbdf8e6525

View File

@ -29,24 +29,6 @@ endif()
# ======================================================== # ========================================================
find_package(Boost REQUIRED) find_package(Boost REQUIRED)
# If building with Catkin, use catkin_package to find dependencies
if(BUILDING_WITH_CATKIN)
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
geometry_msgs
nav_msgs
tf2
tf2_ros
actionlib
dynamic_reconfigure
)
# Find internal packages (these should be built in the same workspace)
# Catkin will handle these through workspace dependencies
find_package(yaml-cpp REQUIRED)
endif()
# ======================================================== # ========================================================
# Source Files # Source Files
@ -61,11 +43,6 @@ include_directories(
${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/include
) )
if(BUILDING_WITH_CATKIN)
include_directories(
${catkin_INCLUDE_DIRS}
)
endif()
# ======================================================== # ========================================================
# RPATH settings: ưu tiên thư vin build ti ch # RPATH settings: ưu tiên thư vin build ti ch
@ -84,84 +61,36 @@ add_library(move_base SHARED ${SOURCES} ${HEADERS})
# ======================================================== # ========================================================
# Dependencies and Link Libraries # Dependencies and Link Libraries
# ======================================================== # ========================================================
if(BUILDING_WITH_CATKIN)
# Catkin mode: use catkin dependencies # Standalone CMake mode: link all dependencies manually
catkin_package( set(PACKAGES_DIR
INCLUDE_DIRS include geometry_msgs
LIBRARIES move_base std_msgs
CATKIN_DEPENDS move_base_core
roscpp nav_core
rospy costmap_2d
std_msgs plugins # Link vi plugins library đ có StaticLayer typeinfo
geometry_msgs yaml-cpp
nav_msgs xmlrpcpp
tf2 tf3_sensor_msgs
tf2_ros tf3_geometry_msgs
actionlib data_convert
dynamic_reconfigure dl
DEPENDS pthread
yaml-cpp robot_nav_2d_utils
Boost )
)
target_link_libraries(move_base
# Link against catkin packages PUBLIC ${PACKAGES_DIR}
target_link_libraries(move_base PUBLIC robot_cpp
${catkin_LIBRARIES} PRIVATE Boost::boost
${Boost_LIBRARIES} )
yaml-cpp
) # Set RPATH đ ưu tiên thư vin build cc b
set_target_properties(move_base PROPERTIES
# Internal packages (assumed to be in same workspace) LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
# These will be linked via catkin workspace dependencies )
target_link_libraries(move_base
move_base_core
nav_core
costmap_2d
plugins # Link vi plugins library đ có StaticLayer typeinfo
xmlrpcpp
robot_cpp
tf3_sensor_msgs
tf3_geometry_msgs
dl
pthread
)
# Set RPATH đ ưu tiên thư vin build cc b
set_target_properties(move_base PROPERTIES
BUILD_RPATH "${CMAKE_BINARY_DIR}/src/Libraries/costmap_2d:${CMAKE_BINARY_DIR}/src/Libraries/node_handle:${CMAKE_BINARY_DIR}/src/Libraries/tf3:${CMAKE_BINARY_DIR}/src/Libraries/robot_time:${CMAKE_BINARY_DIR}/src/Libraries/xmlrpcpp"
INSTALL_RPATH "${CMAKE_BINARY_DIR}/src/Libraries/costmap_2d:${CMAKE_BINARY_DIR}/src/Libraries/node_handle:${CMAKE_BINARY_DIR}/src/Libraries/tf3:${CMAKE_BINARY_DIR}/src/Libraries/robot_time:${CMAKE_BINARY_DIR}/src/Libraries/xmlrpcpp"
LINK_FLAGS "-Wl,--disable-new-dtags"
)
else()
# Standalone CMake mode: link all dependencies manually
set(PACKAGES_DIR
geometry_msgs
std_msgs
move_base_core
nav_core
costmap_2d
plugins # Link vi plugins library đ có StaticLayer typeinfo
yaml-cpp
xmlrpcpp
tf3_sensor_msgs
tf3_geometry_msgs
data_convert
dl
pthread
robot_nav_2d_utils
)
target_link_libraries(move_base
PUBLIC ${PACKAGES_DIR}
PUBLIC robot_cpp
PRIVATE Boost::boost
)
# Set RPATH đ ưu tiên thư vin build cc b
set_target_properties(move_base PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
)
endif()
# ======================================================== # ========================================================
# Include Directories for Target # Include Directories for Target
@ -187,12 +116,6 @@ target_link_libraries(move_base_main
PRIVATE Boost::boost PRIVATE Boost::boost
) )
if(BUILDING_WITH_CATKIN)
target_link_libraries(move_base_main
PRIVATE ${catkin_LIBRARIES}
)
endif()
# Set RPATH for executable to find libraries in build directory first # Set RPATH for executable to find libraries in build directory first
# Use RPATH instead of RUNPATH for higher priority # Use RPATH instead of RUNPATH for higher priority
set_target_properties(move_base_main PROPERTIES set_target_properties(move_base_main PROPERTIES
@ -208,37 +131,25 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--disable-new-dtags")
# ======================================================== # ========================================================
# Installation # Installation
# ======================================================== # ========================================================
if(BUILDING_WITH_CATKIN)
# Catkin installation # Standalone CMake installation
install(DIRECTORY include/move_base install(DIRECTORY include/move_base
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} DESTINATION include
FILES_MATCHING PATTERN "*.h" FILES_MATCHING PATTERN "*.h"
) )
install(TARGETS move_base move_base_main install(TARGETS move_base move_base_main
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} EXPORT move_base-targets
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} LIBRARY DESTINATION lib
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION} ARCHIVE DESTINATION lib
) RUNTIME DESTINATION bin
else() )
# Standalone CMake installation
install(DIRECTORY include/move_base install(EXPORT move_base-targets
DESTINATION include FILE move_base-targets.cmake
FILES_MATCHING PATTERN "*.h" DESTINATION lib/cmake/move_base
) )
install(TARGETS move_base move_base_main
EXPORT move_base-targets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
)
install(EXPORT move_base-targets
FILE move_base-targets.cmake
DESTINATION lib/cmake/move_base
)
endif()
# ======================================================== # ========================================================
# Build Options # Build Options