colcon-cmake
colcon-cmake copied to clipboard
Colcon warning if a package doesn't install anything
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):
- Have the test package install some innocuous empty
hello_world.txt
file. - Set
"cmake-target": "all"
incolcon.pkg
will ensure when a specific target is specified, the install target is no longer added implicitly.
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.