colcon / colcon-cmake

Extension for colcon to support CMake packages
http://colcon.readthedocs.io
Apache License 2.0
16 stars 25 forks source link

cmake --build <path> --target help does not list the "tests" target when using Ninja generator #118

Open alexwpitt opened 2 years ago

alexwpitt commented 2 years ago

The "help" target is used to check if a particular target exists: https://github.com/colcon/colcon-cmake/blob/2e824fdcfb5c3be9e011d6867d293cddbd222f09/colcon_cmake/task/cmake/__init__.py#L92-L93

But when using the Ninja generator, the "tests" target does not seem to appear in the output of that command, and therefore is not built by a colcon build on a ROS package containing cmake such as:

if(CATKIN_ENABLE_TESTING)
  find_package(rostest REQUIRED)
  add_rostest_gtest(dummy_node_test test/dummy_node.test test/DummyNodeTest.cpp)
  target_include_directories(dummy_node_test SYSTEM PRIVATE ${catkin_INCLUDE_DIRS})
  target_link_libraries(dummy_node_test ${catkin_LIBRARIES})
endif()

This causes colcon test failures if rostest tries to launch the unbuilt test binary.