-
Notifications
You must be signed in to change notification settings - Fork 8.2k
doc: cmake: add cmake style guidelines #83713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
7305c71 to
98d0920
Compare
nordicjm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks OK minus nit. in examples
doc/build/cmake/style.rst
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these use 4 space indent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it still uses 4 space indent.
98d0920 to
3bbe790
Compare
doc/build/cmake/style.rst
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps: Use Uppercase for Cache Variables or variables shared across CMake files
as we do have variables that are shared / re-used throughout the CMake tree but are not cache variables.
doc/build/cmake/style.rst
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean function arguments ?
You cannot have two CMake commands on a single line.
Also the example code block has two args on same line my_target and PRIVATE, which I think in this case is perfectly valid, but as PRIVATE technically is independent flag, then it becomes a bit unclear when this is acceptable, and when it should be avoided.
I think I know your intentions, and I agree with them, but current sentence is imprecise.
Sorry for not having a better suggestion atm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, maybe make this about files instead of commands, so this becomes clearte, i.e. One file per line
3bbe790 to
f2a382a
Compare
doc/build/cmake/style.rst
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it still uses 4 space indent.
doc/build/cmake/style.rst
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this uses four space indent.
Btw. do we want just the indent or alignment ?
I'm fine either way, but prefer consistency.
And should function calls spanning multiple lines wrap first arg also, that is if we only indent and not align the args.
A)
target_sources(my_target PRIVATE
src/file1.cpp
src/file2.cpp
)
A.a)
target_sources(
my_target PRIVATE
src/file1.cpp
src/file2.cpp
)
B)
target_sources(my_target PRIVATE
src/file1.cpp
src/file2.cpp
)
doc/build/cmake/style.rst
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this uses 4 space indent.
93c56c2 to
f82fc91
Compare
tejlmand
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A good start 👍
|
Bit late to the party, but has https://github.com/BlankSpruce/gersemi/ been considered to be used instead of putting formatting details (use 2 spaces, no space after if, etc.) into a textual guideline? |
Only attempt of CMake formatting was #82839, I think. |
not sure if this specific formatter has been tried. As a reference, I can also point to: https://discourse.cmake.org/t/cmake-linter/8391 from June 2023 which contains a reply from Craig Scott.
So atm I think the best we can do is to have CMake format recommendations in writing. |
ad8f960 to
e9669de
Compare
Add cmake style guidelines. Signed-off-by: Anas Nashif <[email protected]>
e9669de to
abbc210
Compare
Add cmake style guidelines.
Signed-off-by: Anas Nashif [email protected]