cmake: Sort target_sources alphabetically #12879
Closed
+59
−47
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
Creates a gersemi extension that sorts the elements in
target_sourcesalphabetically (and also removes duplicates). This uses case-sensitive sorting as bd2024e does.The minimum version of gersemi for these extensions is 0.20 as per BlankSpruce/gersemi@4b21bf5, which is below our current minimum of 0.21.
Motivation and Context
Sorting of these lists comes up every so often in PR reviews (see e.g. bd2024e or #12735 (comment)). Having it get sorted automatically (and enforced by CI) should make things easier.
In theory, this could be extended to other lists like
target_link_librariesas well, but from what it looks like, those are usually sorted manually based on other criteria (internalOBS::libraries first, etc)How Has This Been Tested?
Ran the check (
./build-aux/run-gersemi -c) and saw many badly formatted files. Ran the formatter (./build-aux/run-gersemi) and the files changed (to what is in this PR). Ran the check again and had no more badly formatted files.Types of changes
Checklist: