fix file cmake

This commit is contained in:
2025-12-02 10:39:03 +07:00
parent 11ff1baa79
commit 747c9697a2
2 changed files with 35 additions and 35 deletions

View File

@@ -23,11 +23,6 @@ find_package(GTest REQUIRED) # Google Test cho unit test
find_package(PCL REQUIRED COMPONENTS common io) # Point Cloud Library
find_package(xmlrpcpp REQUIRED) # XML-RPC client/server library
# --- Include other message packages nếu cần ---
# Có thể add_subdirectory nếu các package ROS msgs không có target
# ví dụ sensor_msgs, geometry_msgs, nav_msgs,...
# mục đích để build mà không cần cài ROS
# --- Define macro để dùng trong code ---
add_definitions(-DCOSTMAP_2D_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
@@ -86,15 +81,26 @@ target_include_directories(costmap_2d
$<INSTALL_INTERFACE:include/${PROJECT_NAME}> # Khi install
)
# --- Cài đặt thư viện ---
# --- Cài đặt thư viện vào hệ thống khi chạy make install ---
install(TARGETS costmap_2d
EXPORT costmap_2dTargets
EXPORT costmap_2d-targets
ARCHIVE DESTINATION lib # Thư viện tĩnh .a
LIBRARY DESTINATION lib # Thư viện động .so
RUNTIME DESTINATION bin # File thực thi (nếu có)
INCLUDES DESTINATION include # Cài đặt include
)
# --- Xuất export set costmap_2dTargets thành file CMake module ---
# --- Tạo file lib/cmake/costmap_2d/costmap_2dTargets.cmake ---
# --- File này chứa cấu hình giúp project khác có thể dùng ---
# --- Find_package(costmap_2d REQUIRED) ---
# --- Target_link_libraries(my_app PRIVATE costmap_2d::costmap_2d) ---
install(EXPORT costmap_2d-targets
FILE costmap_2d-targets.cmake
NAMESPACE costmap_2d::
DESTINATION lib/cmake/costmap_2d
)
# --- Cài đặt headers ---
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION include/${PROJECT_NAME}
@@ -102,29 +108,23 @@ install(DIRECTORY include/${PROJECT_NAME}/
# --- Plugin libraries ---
# Tạo các plugin shared library
add_library(static_layer SHARED plugins/static_layer.cpp)
target_link_libraries(static_layer costmap_2d ${Boost_LIBRARIES} yaml-cpp)
add_library(plugins
SHARED
plugins/static_layer.cpp
plugins/obstacle_layer.cpp
plugins/inflation_layer.cpp
plugins/voxel_layer.cpp
plugins/critical_layer.cpp
plugins/directional_layer.cpp
plugins/preferred_layer.cpp
plugins/unpreferred_layer.cpp
)
add_library(obstacle_layer SHARED plugins/obstacle_layer.cpp)
target_link_libraries(obstacle_layer costmap_2d ${Boost_LIBRARIES} yaml-cpp)
add_library(inflation_layer SHARED plugins/inflation_layer.cpp)
target_link_libraries(inflation_layer costmap_2d ${Boost_LIBRARIES} yaml-cpp)
add_library(voxel_layer SHARED plugins/voxel_layer.cpp)
target_link_libraries(voxel_layer costmap_2d ${Boost_LIBRARIES} yaml-cpp)
add_library(critical_layer SHARED plugins/critical_layer.cpp)
target_link_libraries(critical_layer costmap_2d static_layer ${Boost_LIBRARIES} yaml-cpp)
add_library(directional_layer SHARED plugins/directional_layer.cpp)
target_link_libraries(directional_layer costmap_2d static_layer ${Boost_LIBRARIES} yaml-cpp)
add_library(preferred_layer SHARED plugins/preferred_layer.cpp)
target_link_libraries(preferred_layer costmap_2d static_layer ${Boost_LIBRARIES} yaml-cpp)
add_library(unpreferred_layer SHARED plugins/unpreferred_layer.cpp)
target_link_libraries(unpreferred_layer costmap_2d static_layer ${Boost_LIBRARIES} yaml-cpp)
target_link_libraries(plugins
costmap_2d
${Boost_LIBRARIES}
yaml-cpp
)
# --- Option để bật/tắt test ---