110 lines
3.5 KiB
CMake
Executable File
110 lines
3.5 KiB
CMake
Executable File
# --- CMake version và project name ---
|
|
cmake_minimum_required(VERSION 3.10)
|
|
project(custom_planner)
|
|
|
|
# --- C++ standard và position independent code ---
|
|
set(CMAKE_CXX_STANDARD 17) # Sử dụng C++17
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON) # Thư viện có thể build thành shared lib
|
|
|
|
# --- RPATH settings: ưu tiên thư viện build tại chỗ ---
|
|
# Dùng để runtime linker tìm thư viện đã build trước khi install
|
|
set(CMAKE_SKIP_BUILD_RPATH FALSE)
|
|
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
|
set(CMAKE_BUILD_RPATH "${CMAKE_BINARY_DIR}/custom_planner")
|
|
set(CMAKE_INSTALL_RPATH "${CMAKE_BINARY_DIR}/custom_planner")
|
|
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
|
|
|
# --- Dependencies ---
|
|
# Tìm các thư viện cần thiết
|
|
# find_package(tf3 REQUIRED) # Nếu dùng tf3
|
|
find_package(Eigen3 REQUIRED) # Thư viện Eigen cho toán học
|
|
find_package(Boost REQUIRED COMPONENTS system thread filesystem) # Boost: system, thread, filesystem
|
|
|
|
# --- Include directories ---
|
|
# Thêm các folder chứa header files
|
|
include_directories(
|
|
include
|
|
${EIGEN3_INCLUDE_DIRS}
|
|
${Boost_INCLUDE_DIRS}
|
|
)
|
|
|
|
# --- Eigen và PCL definitions ---
|
|
add_definitions(${EIGEN3_DEFINITIONS})
|
|
|
|
# --- Core library: custom_planner ---
|
|
# Tạo thư viện chính
|
|
add_library(custom_planner
|
|
src/custom_planner.cpp
|
|
src/pathway.cc
|
|
src/pose.cc
|
|
src/Curve_common.cpp
|
|
src/merge_path_calc.cpp
|
|
)
|
|
|
|
# --- Link các thư viện phụ thuộc ---
|
|
target_link_libraries(custom_planner
|
|
${Boost_LIBRARIES} # Boost
|
|
robot_visualization_msgs
|
|
robot_nav_msgs
|
|
tf3
|
|
robot_tf3_geometry_msgs
|
|
robot_time
|
|
data_convert
|
|
robot_costmap_2d
|
|
nav_core
|
|
robot_protocol_msgs
|
|
)
|
|
|
|
# --- Include directories cho target ---
|
|
target_include_directories(custom_planner
|
|
PUBLIC
|
|
${Boost_INCLUDE_DIRS} # Boost headers
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> # Khi build từ source
|
|
$<INSTALL_INTERFACE:include/${PROJECT_NAME}> # Khi install
|
|
)
|
|
|
|
# --- Cài đặt thư viện vào hệ thống khi chạy make install ---
|
|
install(TARGETS custom_planner
|
|
EXPORT custom_planner-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 robot_costmap_2dTargets thành file CMake module ---
|
|
# --- Tạo file lib/cmake/custom_planner/robot_costmap_2dTargets.cmake ---
|
|
# --- File này chứa cấu hình giúp project khác có thể dùng ---
|
|
# --- Find_package(custom_planner REQUIRED) ---
|
|
# --- Target_link_libraries(my_app PRIVATE custom_planner::custom_planner) ---
|
|
install(EXPORT custom_planner-targets
|
|
FILE custom_planner-targets.cmake
|
|
NAMESPACE custom_planner::
|
|
DESTINATION lib/cmake/custom_planner
|
|
)
|
|
|
|
# --- Cài đặt headers ---
|
|
install(DIRECTORY include/${PROJECT_NAME}/
|
|
DESTINATION include/${PROJECT_NAME}
|
|
)
|
|
|
|
# # --- Plugin libraries ---
|
|
# # Tạo các plugin shared library
|
|
# 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
|
|
# )
|
|
|
|
# target_link_libraries(plugins
|
|
# custom_planner
|
|
# ${Boost_LIBRARIES}
|
|
# yaml-cpp
|
|
# robot_time
|
|
# ) |