ROS2 Error with colcon build and BUILD_TESTING arg
My ros2 version is Foxy on Ubuntu 20.04. Right now I am trying to build a package with colcon that takes in the BUILD_TESTING argument when I do not want tests. The error being output is:
No rule to make target '-DBUILD_TESTING=OFF', needed by 'takeoff_action_node'. Stop.
The command I run is:
colcon build --symlink-install --cmake-args "-DBUILD_TESTING=OFF" --packages-select behavior_trees_ros2
Has anyone resolved this issue before? My CMakeLists.txt is below.
cmake_minimum_required(VERSION 3.5)
project(behavior_trees_ros2)
# Default to C99
if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 99)
endif()
# Default to C++17
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_action REQUIRED)
find_package(companion_computing_interfaces REQUIRED)
include_directories(
include
${Boost_INCLUDE_DIR}
${companion_computing_interfaces_INCLUDE_DIRS}
)
add_subdirectory(libs)
add_executable(takeoff_action_node
examples/armtakeoff.cpp
src/nuav_nodes/ArmTakeoff.cpp
)
target_include_directories(takeoff_action_node PUBLIC libs/behavior-trees/include)
target_link_libraries(takeoff_action_node behavior_trees)
add_executable(gotostatic_action_node
examples/gotostatic.cpp
src/nuav_nodes/ArmTakeoff.cpp
src/nuav_nodes/GotoStatic.cpp
)
target_include_directories(gotostatic_action_node PUBLIC libs/behavior-trees/include)
target_link_libraries(gotostatic_action_node behavior_trees)
add_executable(figure8_mission
examples/figure8.cpp
src/nuav_nodes/ArmTakeoff.cpp
src/nuav_nodes/GotoStatic.cpp
src/nuav_nodes/Land.cpp
)
target_include_directories(figure8_mission PUBLIC libs/behavior-trees/include)
target_link_libraries(figure8_mission behavior_trees)
add_executable(analyze_exposure_mission
examples/analyze_exposure.cpp
src/nuav_nodes/ArmTakeoff.cpp
src/nuav_nodes/GotoStatic.cpp
src/nuav_nodes/Land.cpp
src/nuav_nodes/DecreaseExposure.cpp
)
target_include_directories(analyze_exposure_mission PUBLIC libs/behavior-trees/include)
target_link_libraries(analyze_exposure_mission behavior_trees)
add_executable(aruco_land_collect_mission
examples/aruco_land_collection.cpp
src/nuav_nodes/ArmTakeoff.cpp
src/nuav_nodes/Land.cpp
src/nuav_nodes/DecreaseExposure.cpp
)
target_include_directories(aruco_land_collect_mission PUBLIC libs/behavior-trees/include)
target_link_libraries(aruco_land_collect_mission behavior_trees)
set(dependencies
rclcpp
rclcpp_action
companion_computing_interfaces
)
set(${PROJECT_NAME}_SRCS
src/nuav_nodes/ArmTakeoff.cpp
src/nuav_nodes/GotoStatic.cpp
src/nuav_nodes/Land.cpp
src/nuav_nodes/DecreaseExposure.cpp
src/examples/main.cpp
)
add_library(${PROJECT_NAME}
src/nuav_nodes/ArmTakeoff.cpp
src/nuav_nodes/GotoStatic.cpp
src/nuav_nodes/Land.cpp
src/nuav_nodes/DecreaseExposure.cpp
)
target_include_directories(${PROJECT_NAME} PUBLIC libs/behavior-trees/include)
target_link_libraries(${PROJECT_NAME} behavior_trees)
ament_target_dependencies(takeoff_action_node ${dependencies})
ament_target_dependencies(gotostatic_action_node ${dependencies})
ament_target_dependencies(figure8_mission ${dependencies})
ament_target_dependencies(analyze_exposure_mission ${dependencies})
ament_target_dependencies(aruco_land_collect_mission ${dependencies})
ament_target_dependencies(${PROJECT_NAME} ${dependencies})
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
# uncomment the line when a copyright and license is not present in all source files
#set(ament_cmake_copyright_FOUND TRUE)
# the following line skips cpplint (only works in a git repo)
# uncomment the line when this package is not in a git repo
#set(ament_cmake_cpplint_FOUND TRUE)
find_package(ament_cmake_gtest REQUIRED)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
ament_add_gtest(test_nuav_nodes test/test_nuav_nodes.cpp)
if(TARGET test_nuav_nodes)
ament_target_dependencies(test_nuav_nodes
${dependencies}
)
target_link_libraries(test_nuav_nodes ${PROJECT_NAME})
endif()
endif()
install(TARGETS
takeoff_action_node
gotostatic_action_node
figure8_mission
analyze_exposure_mission
aruco_land_collect_mission
DESTINATION lib/${PROJECT_NAME})
ament_package()
It should probably be:
No quotes around the CMake args.