optimal & fix file cmake
This commit is contained in:
107
CMakeLists.txt
107
CMakeLists.txt
@@ -55,8 +55,10 @@ if(NOT BUILDING_WITH_CATKIN)
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../../.."
|
||||
)
|
||||
|
||||
# Test/recovery_core -> Test -> AMR_T800 -> src -> <workspace>. Bốn cấp, không phải bảy: bảy là
|
||||
# di sản từ vị trí cũ của gói và trỏ vào một thư mục không tồn tại.
|
||||
set(WORKSPACE_DEVEL_LIB_DIR
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../devel/lib"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../devel/lib"
|
||||
)
|
||||
|
||||
|
||||
@@ -135,6 +137,8 @@ if(NOT BUILDING_WITH_CATKIN)
|
||||
# ========================================================
|
||||
else()
|
||||
|
||||
# nav_test_harness chỉ dùng cho test (fake clock/costmap/pose/collision), nên nó KHÔNG nằm trong
|
||||
# catkin_package(CATKIN_DEPENDS) — consumer của recovery_core không phải kéo theo nó.
|
||||
find_package(catkin REQUIRED COMPONENTS
|
||||
robot_costmap_2d
|
||||
robot_cpp
|
||||
@@ -142,6 +146,7 @@ else()
|
||||
robot_geometry_msgs
|
||||
robot_nav_msgs
|
||||
robot_xmlrpcpp
|
||||
nav_test_harness
|
||||
)
|
||||
|
||||
|
||||
@@ -161,10 +166,10 @@ else()
|
||||
|
||||
LIBRARIES
|
||||
recovery_core
|
||||
recovery_core_wait_recovery
|
||||
recovery_core_clear_costmap_recovery
|
||||
recovery_core_rotate_recovery
|
||||
recovery_core_back_up_recovery
|
||||
recovery_core_regen_path_recovery
|
||||
|
||||
CATKIN_DEPENDS
|
||||
robot_costmap_2d
|
||||
@@ -181,7 +186,11 @@ else()
|
||||
|
||||
include_directories(
|
||||
include
|
||||
)
|
||||
|
||||
# Header của dependency vào dạng SYSTEM: gói này build với -Wall -Wextra, mà robot_cpp/costmap_2d
|
||||
# sinh hàng trăm warning riêng của chúng — để lẫn vào thì warning của chính gói này vô hình.
|
||||
include_directories(SYSTEM
|
||||
${catkin_INCLUDE_DIRS}
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${TF3_INCLUDE_DIR}
|
||||
@@ -196,8 +205,16 @@ endif()
|
||||
add_library(recovery_core SHARED
|
||||
src/recovery_types.cpp
|
||||
src/recovery_behavior.cpp
|
||||
src/recovery_registry.cpp
|
||||
|
||||
# Adapter nối cổng của contract vào costmap thật. Nằm trong lib chính (không phải plugin) vì
|
||||
# host dựng chúng trực tiếp, không nạp qua Boost.DLL.
|
||||
adapters/costmap_pose_provider.cpp
|
||||
adapters/costmap_collision_checker.cpp
|
||||
)
|
||||
|
||||
target_compile_options(recovery_core PRIVATE -Wall -Wextra)
|
||||
|
||||
|
||||
# ========================================================
|
||||
# Core library - Catkin
|
||||
@@ -306,6 +323,9 @@ function(add_recovery_core_plugin target source)
|
||||
)
|
||||
|
||||
|
||||
target_compile_options(${target} PRIVATE -Wall -Wextra)
|
||||
|
||||
|
||||
add_dependencies(
|
||||
${target}
|
||||
recovery_core
|
||||
@@ -427,6 +447,13 @@ endfunction()
|
||||
# ========================================================
|
||||
# Recovery plugins
|
||||
# ========================================================
|
||||
# Bộ recovery DEFAULT của gói. Thứ tự chạy do YAML quyết định (mục 3.4 của NAV_REFACTOR_PLAN.md),
|
||||
# không phải thứ tự khai báo ở đây.
|
||||
add_recovery_core_plugin(
|
||||
recovery_core_wait_recovery
|
||||
plugins/wait_recovery.cpp
|
||||
)
|
||||
|
||||
add_recovery_core_plugin(
|
||||
recovery_core_clear_costmap_recovery
|
||||
plugins/clear_costmap_recovery.cpp
|
||||
@@ -442,11 +469,6 @@ add_recovery_core_plugin(
|
||||
plugins/back_up_recovery.cpp
|
||||
)
|
||||
|
||||
add_recovery_core_plugin(
|
||||
recovery_core_regen_path_recovery
|
||||
plugins/regen_path_recovery.cpp
|
||||
)
|
||||
|
||||
|
||||
# ========================================================
|
||||
# Install - Catkin
|
||||
@@ -547,10 +569,10 @@ else()
|
||||
message(STATUS "C++ Standard: ${CMAKE_CXX_STANDARD}")
|
||||
message(STATUS "Libraries:")
|
||||
message(STATUS " recovery_core")
|
||||
message(STATUS " recovery_core_wait_recovery")
|
||||
message(STATUS " recovery_core_clear_costmap_recovery")
|
||||
message(STATUS " recovery_core_rotate_recovery")
|
||||
message(STATUS " recovery_core_back_up_recovery")
|
||||
message(STATUS " recovery_core_regen_path_recovery")
|
||||
message(STATUS "Dependencies:")
|
||||
message(STATUS " robot_costmap_2d")
|
||||
message(STATUS " robot_cpp")
|
||||
@@ -569,17 +591,66 @@ endif()
|
||||
# ========================================================
|
||||
# Tests
|
||||
# ========================================================
|
||||
option(
|
||||
BUILD_RECOVERY_CORE_TESTS
|
||||
"Build recovery_core tests"
|
||||
ON
|
||||
)
|
||||
# Đăng ký qua catkin_add_gtest để `catkin_make run_tests` / `ctest` bắt được, đồng thời vẫn chạy
|
||||
# trực tiếp được binary trong devel/lib/recovery_core.
|
||||
if(CATKIN_ENABLE_TESTING AND BUILDING_WITH_CATKIN)
|
||||
|
||||
|
||||
if(BUILD_RECOVERY_CORE_TESTS)
|
||||
|
||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt)
|
||||
add_subdirectory(test)
|
||||
if(NOT COMMAND catkin_add_gtest)
|
||||
message(FATAL_ERROR "catkin_add_gtest NOT FOUND")
|
||||
endif()
|
||||
|
||||
set(RECOVERY_CORE_TESTS
|
||||
recovery_lifecycle_test
|
||||
output_kind_test
|
||||
goal_semantics_test
|
||||
timeout_test
|
||||
wait_recovery_test
|
||||
backup_safety_test
|
||||
pose_progress_test
|
||||
rotate_safety_test
|
||||
registry_test
|
||||
)
|
||||
|
||||
foreach(test_name ${RECOVERY_CORE_TESTS})
|
||||
catkin_add_gtest(${test_name} test/${test_name}.cpp)
|
||||
|
||||
if(TARGET ${test_name})
|
||||
set_target_properties(${test_name} PROPERTIES EXCLUDE_FROM_ALL FALSE)
|
||||
|
||||
target_compile_options(${test_name} PRIVATE -Wall -Wextra)
|
||||
|
||||
target_include_directories(${test_name}
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test
|
||||
)
|
||||
|
||||
target_include_directories(${test_name} SYSTEM
|
||||
PRIVATE
|
||||
${catkin_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
# catkin_add_gtest dùng target_link_libraries dạng plain, nên phần bổ sung cũng phải plain.
|
||||
# Plugin KHÔNG được link thẳng: chúng chỉ export alias Boost.DLL và được nạp qua
|
||||
# RecoveryRegistry, đúng đường mà runtime đi.
|
||||
target_link_libraries(${test_name}
|
||||
recovery_core
|
||||
${catkin_LIBRARIES}
|
||||
${Boost_LIBRARIES}
|
||||
yaml-cpp
|
||||
pthread
|
||||
${CMAKE_DL_LIBS}
|
||||
)
|
||||
|
||||
add_dependencies(${test_name} ${RECOVERY_CORE_PLUGIN_TARGETS})
|
||||
|
||||
# Đường tới cây config test và thư mục .so, để binary tự trỏ đúng chỗ khi chạy qua ctest
|
||||
# (ctest không mang theo PNKX_NAV_CORE_CONFIG_DIR hay LD_LIBRARY_PATH của shell).
|
||||
target_compile_definitions(${test_name} PRIVATE
|
||||
RECOVERY_CORE_TEST_CONFIG_DIR="${CMAKE_CURRENT_SOURCE_DIR}/test/config"
|
||||
RECOVERY_CORE_TEST_LIBRARY_DIR="${CATKIN_DEVEL_PREFIX}/lib"
|
||||
)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
endif()
|
||||
Reference in New Issue
Block a user