colcon / colcon-cmake

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

Colcon warning if a package doesn't install anything #122

Open quarkytale opened 2 years ago

quarkytale commented 2 years ago

A package not integrating any artifacts, makes the build system think there's a bug and it throws out a warning. It's usually ignored for packages not intended to be ever distributed.

https://github.com/colcon/colcon-cmake/blob/20972f195f5d4887475df0d7184f0a7910155821/colcon_cmake/task/cmake/build.py#L115-L117

But in some cases, like for a package whose entire purpose is to run tests and is only integrated when -DBUILD_TESTING=ON, the above assumption doesn't hold true.

If the warning is bothersome, brute force fixes (just for reference):

The short-term clean fix is to include the required artifacts will added when BUILD_TESTING is true and allowing the ament_package() call to happen even when its false, resulting in the package.xml getting installed. See test_rclcpp example.

if(BUILD_TESTING)
  ### code block
endif()

# TODO should not install anything
ament_package()

A more elegant but time consuming fix might be to add support for a field in colcon.pkg "ignore-no-install-target": true which does nothing but suppresses that message when there is no install target. Then give these packages a colcon.pkg file that's simply

{
    "ignore-no-install-target": true
}

This is an under-serviced scenario for both ament and colcon. The "no install target" warning message should not be disabled entirely. Possibly a new package type for test-only CMake projects could be introduced, but needs further discussion.