build: add BUILD_RECOVERY_CORE_TESTS, nav_test_harness only for tests
Tests used to build whenever CATKIN_ENABLE_TESTING was on. They now also need -DBUILD_RECOVERY_CORE_TESTS=ON. nav_test_harness is a test-only package that exists only on the development machine. It was a catkin component, so configuring recovery_core failed on any machine without it. It is now found inside the test block only and declared as test_depend.
This commit is contained in:
@@ -124,8 +124,9 @@ 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ó.
|
||||
# nav_test_harness KHÔNG nằm ở đây: gói chỉ có trên máy dev, chỉ test dùng (fake
|
||||
# clock/costmap/pose/collision). Nó được find_package riêng trong khối test, để máy không có gói
|
||||
# này vẫn build được recovery_core.
|
||||
find_package(catkin REQUIRED COMPONENTS
|
||||
robot_costmap_2d
|
||||
robot_cpp
|
||||
@@ -133,7 +134,6 @@ else()
|
||||
robot_geometry_msgs
|
||||
robot_nav_msgs
|
||||
robot_xmlrpcpp
|
||||
nav_test_harness
|
||||
)
|
||||
|
||||
|
||||
@@ -580,12 +580,18 @@ endif()
|
||||
# ========================================================
|
||||
# Đă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)
|
||||
# Test mặc định OFF trong cả hai chế độ build; bật bằng -DBUILD_RECOVERY_CORE_TESTS=ON.
|
||||
option(BUILD_RECOVERY_CORE_TESTS "Build the recovery_core unit tests" OFF)
|
||||
|
||||
if(BUILD_RECOVERY_CORE_TESTS AND CATKIN_ENABLE_TESTING AND BUILDING_WITH_CATKIN)
|
||||
|
||||
if(NOT COMMAND catkin_add_gtest)
|
||||
message(FATAL_ERROR "catkin_add_gtest NOT FOUND")
|
||||
endif()
|
||||
|
||||
# Bộ fake dùng chung cho test. Chỉ tìm khi bật test: gói này chỉ có trên máy dev.
|
||||
find_package(nav_test_harness REQUIRED)
|
||||
|
||||
# Plugin giả cho ABI guard test: build cùng test, KHÔNG nằm trong RECOVERY_CORE_PLUGIN_TARGETS
|
||||
# (install đã chạy phía trên) nên không được cài.
|
||||
add_recovery_core_plugin(recovery_core_test_stale_abi test/plugins/stale_abi_recovery.cpp)
|
||||
@@ -619,6 +625,7 @@ if(CATKIN_ENABLE_TESTING AND BUILDING_WITH_CATKIN)
|
||||
target_include_directories(${test_name} SYSTEM
|
||||
PRIVATE
|
||||
${catkin_INCLUDE_DIRS}
|
||||
${nav_test_harness_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
# catkin_add_gtest dùng target_link_libraries dạng plain, nên phần bổ sung cũng phải plain.
|
||||
@@ -627,6 +634,7 @@ if(CATKIN_ENABLE_TESTING AND BUILDING_WITH_CATKIN)
|
||||
target_link_libraries(${test_name}
|
||||
recovery_core
|
||||
${catkin_LIBRARIES}
|
||||
${nav_test_harness_LIBRARIES}
|
||||
${Boost_LIBRARIES}
|
||||
yaml-cpp
|
||||
pthread
|
||||
|
||||
@@ -44,8 +44,8 @@
|
||||
<build_depend>yaml-cpp</build_depend>
|
||||
<run_depend>yaml-cpp</run_depend>
|
||||
|
||||
<!-- Chỉ dùng cho test: fake clock/costmap/pose/collision. Cố ý KHÔNG có run_depend và không nằm
|
||||
trong catkin_package(CATKIN_DEPENDS) — consumer của recovery_core không phải kéo theo nó. -->
|
||||
<build_depend>nav_test_harness</build_depend>
|
||||
<!-- Chỉ dùng cho test: fake clock/costmap/pose/collision. Gói chỉ có trên máy dev, nên chỉ là
|
||||
test_depend; CMake chỉ find_package nó khi bật BUILD_RECOVERY_CORE_TESTS. -->
|
||||
<test_depend>nav_test_harness</test_depend>
|
||||
|
||||
</package>
|
||||
|
||||
Reference in New Issue
Block a user