cheshirekow / cmake_format

Source code formatter for cmake listfiles.
GNU General Public License v3.0
962 stars 105 forks source link

Choose vertical/horizontal wrapping based on line length #293

Open mmatrosov opened 2 years ago

mmatrosov commented 2 years ago

Take a look at this code formatted with default settings:

install(
  FILES log_handler.cpp
  DESTINATION "usr/local/bin"
  COMPONENT bin)

I would prefer it not to be wrapped at all. I set max_subgroups_hwrap to 3 and get:

install(FILES log_handler.cpp DESTINATION "usr/local/bin" COMPONENT bin)

This is great. Then I decide to add more files to the command and get this:

install(FILES log_handler.cpp some_file.cpp some_otherfile.cpp
              and_another_file.cpp DESTINATION "usr/local/bin" COMPONENT bin)

Now this is bad, I don't like this formatting at all. I want a newline before DESTINATION. I can set max_lines_hwrap to 0 and in this particular case it works fine:

install(
  FILES log_handler.cpp some_file.cpp some_otherfile.cpp and_another_file.cpp
  DESTINATION "usr/local/bin"
  COMPONENT bin)

but in other cases I don't want to change max_lines_hwrap.

I have a feeling that what I want is impossible to achieve given the current options from the config. I need something like "put all groups on one line, but when the col-limit is reached, wrap them ALL vertically". Is this possible?