build: default the tests to the build mode instead of always on
The standalone CMake build is the robot deployment path and must not produce test executables; a catkin workspace is a development machine and keeps them. Force with -D<option>=ON to build the tests from a standalone build.
This commit is contained in:
@@ -143,7 +143,13 @@ endif()
|
||||
# ========================================================
|
||||
# Test executables
|
||||
# ========================================================
|
||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/time.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_TIME_TESTS=ON to build them
|
||||
# from a standalone build.
|
||||
option(BUILD_ROBOT_TIME_TESTS "Build the robot_time unit tests" ${BUILDING_WITH_CATKIN})
|
||||
|
||||
if(BUILD_ROBOT_TIME_TESTS AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/time.cpp)
|
||||
add_executable(${PROJECT_NAME}_test test/time.cpp)
|
||||
target_link_libraries(${PROJECT_NAME}_test PRIVATE
|
||||
${PROJECT_NAME}
|
||||
@@ -152,7 +158,7 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/time.cpp)
|
||||
)
|
||||
endif()
|
||||
|
||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/duration.cpp)
|
||||
if(BUILD_ROBOT_TIME_TESTS AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/duration.cpp)
|
||||
add_executable(${PROJECT_NAME}_duration_test test/duration.cpp)
|
||||
target_link_libraries(${PROJECT_NAME}_duration_test PRIVATE
|
||||
${PROJECT_NAME}
|
||||
@@ -162,7 +168,7 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/duration.cpp)
|
||||
endif()
|
||||
|
||||
# Standalone WallTime test (header-only)
|
||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/walltime_standalone_test.cpp)
|
||||
if(BUILD_ROBOT_TIME_TESTS AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/walltime_standalone_test.cpp)
|
||||
add_executable(${PROJECT_NAME}_walltime_standalone_test test/walltime_standalone_test.cpp)
|
||||
target_include_directories(${PROJECT_NAME}_walltime_standalone_test PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
|
||||
Reference in New Issue
Block a user