(→Upper/lower casing: update to new syntaxhighlighter) |
|||
| Line 16: | Line 16: | ||
CMake commands are case-insensitive (only the commands, not the arguments or variable names). So all the following versions work: | CMake commands are case-insensitive (only the commands, not the arguments or variable names). So all the following versions work: | ||
| − | < | + | <syntaxhighlight lang="cmake"> |
add_executable(foo foo.c) | add_executable(foo foo.c) | ||
ADD_EXECUTABLE(bar bar.c) | ADD_EXECUTABLE(bar bar.c) | ||
Add_Executable(hello hello.c) | Add_Executable(hello hello.c) | ||
aDd_ExEcUtAbLe(blub blub.c) | aDd_ExEcUtAbLe(blub blub.c) | ||
| − | </ | + | </syntaxhighlight> |
But this would be ugly. | But this would be ugly. | ||
| Line 27: | Line 27: | ||
In KDE the ''all-lowercase style is preferred''. The all-uppercase style is also ok. Mixing upper- and lowercase should not be done in KDE CMake files. | In KDE the ''all-lowercase style is preferred''. The all-uppercase style is also ok. Mixing upper- and lowercase should not be done in KDE CMake files. | ||
Although all-lowercase is preferred, if a file is apparently in all-uppercase style, then stay consistent and also use all-uppercase in this file. | Although all-lowercase is preferred, if a file is apparently in all-uppercase style, then stay consistent and also use all-uppercase in this file. | ||
| − | |||
==(Not) Using pkg-config== | ==(Not) Using pkg-config== | ||
This document describes the recommended coding style for CMake files in KDE, i.e. CMakeLists.txt files and *.cmake files.
Contents |
Indent all code correctly, i.e. the body of
Use spaces for indenting, 2, 3 or 4 spaces preferably. Use the same amount of spaces for indenting as is used in the rest of the file.
CMake commands are case-insensitive (only the commands, not the arguments or variable names). So all the following versions work:
add_executable(foo foo.c) ADD_EXECUTABLE(bar bar.c) Add_Executable(hello hello.c) aDd_ExEcUtAbLe(blub blub.c)
But this would be ugly.
In KDE the all-lowercase style is preferred. The all-uppercase style is also ok. Mixing upper- and lowercase should not be done in KDE CMake files. Although all-lowercase is preferred, if a file is apparently in all-uppercase style, then stay consistent and also use all-uppercase in this file.
You are free to use pkg-config in FindXXX.cmake modules, as long as the following conditions are met:
Follow the style guide from CMake when writing some FindFoo.cmake module: readme.txt