catkin pkg config template: performance fix for pack/unpack/append #1137
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.
rationale
These algorithms may be used O(M^2) times where M is the level of rospackage nesting, and each pack/unpack/append algorithm complexity are O(N^2)/O(N)/O(N^2) where N is libraries count. The fix allows to reduce them to O(1) complexity if we only consider amount of cmake statements executed. In a ros distro where level of nesting may exceed 10 and library count a couple of hundreds, cmake execution time can easily take more than 30 seconds, which becomes prohibitive.
reproduction
https://github.com/aurzenligl/study/tree/master/ros-catkin-pkgconfig
notes
Notes regarding REMOVE_DUPLICATES in list_append_unique and list_append_deduplicate are incorrect, in case of:
3.0.2: https://github.com/Kitware/CMake/blob/v3.0.2/Source/cmListCommand.cxx#L480-L493
3.19.6: https://github.com/Kitware/CMake/blob/v3.19.6/Source/cmAlgorithms.h#L120-L130