Add DEPENDS_EXPLICIT_ONLY to remove implicit dependencies #910
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR addresses one of the build speedup mentioned in #859.
When
add_custom_command
is used to generate files that are then used by a target, theadd_custom_command
becomes implicitly dependent on the target dependencies. In rosidladd_custom_command
is used to generate files from the IDL files, the generator does not depend on anything else (except rosidl_generator_c[pp] whose generators depend on rosidl_generator_type_description).This PR (and the equivalent for rosidl_typesupport, rosidl_typesupport_fastrtps and rosidl_python) adds the
DEPENDS_EXPLICIT_ONLY
option of add_custom_command to most generators (except for C/CPP).Note
This option is only useful when using Ninja. When testing use
--cmake-args -GNinja
Since the generators are no longer constrained by unnecessary dependencies, they can start immediately. This speeds up the build significantly (2x for px4_msgs on my machine).
Warning
DEPENDS_EXPLICIT_ONLY requires cmake 3.27. The version that ships with Ubuntu 24.04 is 3.28, not sure about other supported distributions.
Right now I've bumped the required version to 3.27 but I could instead only add the option when the cmake version is sufficient (if that's preferable ?).
Note
I wanted to also add the option to rosidl_generator_c[pp] and explicitly specify the dependency to rosidl_generator_type_description. I couldn't figure out how to make it work.
Is this user-facing behavior change?
Did you use Generative AI?
no
Additional Information
I've already created PRs for the other packages. I've set then to Draft until this PR is reviewed.