diff --git a/robot_nav_msgs/CMakeLists.txt b/robot_nav_msgs/CMakeLists.txt index 4e6e463..9f8e95c 100644 --- a/robot_nav_msgs/CMakeLists.txt +++ b/robot_nav_msgs/CMakeLists.txt @@ -146,7 +146,13 @@ endif() # ======================================================== # Test executables # ======================================================== -if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/main.cpp) +# 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_ROBOT_NAV_MSGS_TESTS=ON to build them +# from a standalone build. +option(BUILD_ROBOT_NAV_MSGS_TESTS "Build the robot_nav_msgs unit tests" ${BUILDING_WITH_CATKIN}) + +if(BUILD_ROBOT_NAV_MSGS_TESTS AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/main.cpp) add_executable(${PROJECT_NAME}_test test/main.cpp) target_link_libraries(${PROJECT_NAME}_test PRIVATE ${PROJECT_NAME}) endif()