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)