Open tawmoto opened 4 years ago
You should be able to accomplish what you want by modifying https://cmake-format.readthedocs.io/en/latest/configopts.html#layout-passes
I don't have an example off the top of my head but maybe you can start with
layout_passes = {
"StatementNode": [(0,False), (5, False)]
}
and play around with it from there.
You should be able to accomplish what you want by modifying https://cmake-format.readthedocs.io/en/latest/configopts.html#layout-passes
I don't have an example off the top of my head but maybe you can start with
layout_passes = { "StatementNode": [(0,False), (5, False)] }
and play around with it from there.
I will try this solution.
But what is the cmdline option for this? Because --layout-passes = {..}
does not work.
Thank you
@cheshirekow The tool acts very strange, sometimes splits from a single line to a multiline and sometimes (very similar) replaces the multiline with a single line. (check the first set
and the list
commands, please)
But what is the cmdline option for this? Because --layout-passes = {..} does not work.
There is no command line version for this one. You'll need to use a config file.
sometimes splits from a single line to a multiline and sometimes (very similar) replaces the multiline with a single line.
You're referring to set()
or list()
in your example?
In general, if a statement fits on one line then cmake-format will prefer to keep it on one line unless any of the configuration thresholds are exceeded.
You're referring to
set()
orlist()
in your example?
I am referring to first set
and the list
.
In general, if a statement fits on one line then cmake-format will prefer to keep it on one line unless any of the configuration thresholds are exceeded.
The list
has ~60 chars and my column limit is 12 chars, I don't understand why the list
is formatted on multiple lines. That is the problem. :-)
What's wrong with the first set()
?
Can you share what options you're using? Also, please paste text instead of screenshots so that I can copy-paste instead of transcribing.
With default configuration I get the following format:
if(AVCP_SYSTEM_WIN)
list(APPEND exception_srcs src/windows/exception.cpp)
endif()
If your column limit (--line-width
?) is 12 chars, then what would you expect with a 60 char line? cmake-format
will try to wrap the text to fit in the 12-wide column which is, of course, impossible. So you end up with "the best it could do".
Though, I suspect you might mean something else or have some other options active, because with a column limit of 12 I get the following (note the wrapped parentheses).
if(AVCP_SYSTEM_WIN
)
list(
APPEND
exception_srcs
src/windows/exception.cpp
)
endif()
@cheshirekow thanks a lot for you nice support, we decided not to use cmake-format at the moment so I don't have the settings anymore but when I will start working with it again (hopefully in the near future), I will get back to you in this matter. Thanks again! :-)
Hi, it seems that cmake-format aligns wrongly the parameters.See above picture: left = correct, right = incorrect. How can I configure it to align it like in the left part? Thanks
My command is