Closed hrzlgnm closed 4 months ago
Thank you for your attempt. Unfortunately I'm not interested in such feature mostly because of these reasons. Furthermore even if someone were to convince me somehow it's a great idea I'd need to do at least these things:
Regarding 1. you might guess that list of files in target_sources
is safe to sort and you are probably right but at the moment I wouldn't bet my money on that.
Thank you for your attempt. Unfortunately I'm not interested in such feature mostly because of these reasons. Furthermore even if someone were to convince me somehow it's a great idea I'd need to do at least these things:
- Well define and research (in respect to the official CMake commands) what's safe to sort, what "rule" do the multiple arguments have to follow for it to be safe etc. "Rule" could be something like "list of source files" or "not list of targets". Something that will make the process in the next point easier to perform and easier to apply to new commands in the future whenever they appear.
- Having established the above go through every single command and add support for that - in my framework it's rather simple operation but the arduous part is going through the docs and reading definitions.
- Consider how to expose this facility to custom commands.
Regarding 1. you might guess that list of files in
target_sources
is safe to sort and you are probably right but at the moment I wouldn't bet my money on that.
Thank you for your detailed feedback about this. I'll think about it if it's worth to do it for such a little benefit.
I'm closing this PR. As I agree that sorting of lists is not something to be done by a formatter, thanks @BlankSpruce for your detailed feedback and reasons not to do it 👍
I was looking for such an option in cmake_format, but could not find a suitable one, as cmake_format only allows sorting in
add_library
andadd_executable
, i was looking for something more general and started toying around in your code.This PR adds a --autosort options which sorts lists with multiple arguments alphabetically, like for example
becomes
Which makes adding new files / link libraries and so on a bit smoother in terms of avoiding conflicts when using git.
Issues to address to leave the draft stage:
set
Is there any interest in such a feature?