From bac3ae0ba3f3059178dfbb3de88bc13145601f3d Mon Sep 17 00:00:00 2001 From: duongtd Date: Sat, 15 Aug 2026 12:42:08 +0700 Subject: [PATCH] build: default the contract tests to the build mode instead of always on The standalone CMake build is the robot deployment path and must not produce a test executable; a catkin workspace is a development machine and keeps it. Dropping include(CTest) also stops this package from defining BUILD_TESTING=ON for the whole tree, which switched every other package's tests back on in the aggregate standalone build. --- CMakeLists.txt | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 70afa63..e790029 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,12 +115,23 @@ endif() # Focused contract tests use a tiny self-contained runner so both catkin and # standalone builds exercise the same code without adding a test dependency. -if(NOT BUILDING_WITH_CATKIN) - include(CTest) -endif() +# +# Tests are a development-machine concern: a catkin workspace is where they run, +# while the standalone CMake build is the robot deployment path and must not +# produce test executables. Force with -DBUILD_DOCK_PLANNER_TESTS=ON to build +# them from a standalone build. +# +# include(CTest) used to sit here for the standalone branch. It is deliberately +# gone: it defines BUILD_TESTING=ON for the WHOLE CMake tree, which switched the +# tests of every other package in the aggregate build back on. +option(BUILD_DOCK_PLANNER_TESTS "Build the dock_planner contract tests" + ${BUILDING_WITH_CATKIN}) -if((BUILDING_WITH_CATKIN AND CATKIN_ENABLE_TESTING) OR - (NOT BUILDING_WITH_CATKIN AND BUILD_TESTING)) +if(BUILD_DOCK_PLANNER_TESTS AND + (NOT BUILDING_WITH_CATKIN OR CATKIN_ENABLE_TESTING)) + if(NOT BUILDING_WITH_CATKIN) + enable_testing() + endif() add_executable(${PROJECT_NAME}_test test/dock_planner_test.cpp) target_link_libraries(${PROJECT_NAME}_test PRIVATE ${PROJECT_NAME}) if(BUILDING_WITH_CATKIN)