Hello,

Can we please modify the KDE coding guidelines for CMake source code
https://community.kde.org/Policies/CMake_Coding_Style
Such that we do not allow the following three issues:

1. kconfig/src/core/CMakeLists.txt:36: Mismatching spaces inside ()
after command [whitespace/mismatch]:
"configure_file(config-kconfig.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/config-kconfig.h )"

Notice that the opening parentheses is followed by zero spaces while
the closing parentheses has a space before it.

2. kconfig/CMakeLists.txt:74: Extra spaces between 'include' and its
() [whitespace/extra]:
"include (ECMPoQmTools)"

This is about not having whitespace between a "CMake command" and its "(".

Reasons: 90% of the lines from the cmake source code files from the
KDE project already respect this rule.
I cannot easily find a space between a cmake command and its "(" in
the documentation and tutorials from the CMake project e.g.
https://cmake.org/cmake/help/git-master/ ,
https://cmake.org/cmake/help/book/mastering-cmake/chapter/Writing%20CMakeLists%20Files.html
The cmake documentation about the cmake command "if" does not suggest
that a space is possible between "if" and its "(".
https://cmake.org/cmake/help/latest/command/if.html
cmake guidelines not from the cmake project tend to not use a space
between "if" and its "(". E.g.
https://learn.microsoft.com/en-us/vcpkg/contributing/cmake-guidelines
https://llvm.org/docs/CMakePrimer.html
There are cmake source code files from the KDE community which (in the
same file) use both styles e.g. "if(" and "if (".
https://invent.kde.org/utilities/kcalc/-/blob/master/CMakeLists.txt
The former project "kdeexamples" does not use space between a cmake
command and its "(".
https://invent.kde.org/unmaintained/kdeexamples/-/blob/ImprovedConfigDotCMakeFile/buildsystem/HowToInstallALibrary/CMakeLists.txt

3. kcalc/CMakeLists.txt:96: Line ends in whitespace [whitespace/eol]:
"   kcalc_const_menu.cpp "

There is a space character after "kcalc_const_menu.cpp".

Thank you.
End of email, please ignore the rest of this email.





Technical details:

The cmake lint messages are from https://pypi.org/project/cmakelint/ .

I could not find a CMake source code guidelines web page from the CMake project.

The KDE coding guidelines for CMake source code
https://community.kde.org/Policies/CMake_Coding_Style already do not
allow the following issues:

1. kconfig/autotests/kconfig_compiler/CMakeLists.txt:8: Do not mix
upper and lower case commands [readability/mixedcase]:
"macro(GEN_KCFG_TEST_SOURCE _testName _srcs)
    KCONFIG_ADD_KCFG_FILES(${_srcs} ${_testName}.kcfgc ${ARGN})
endmacro()"

https://community.kde.org/Policies/CMake_Coding_Style#Upper/lower_casing
says: "Upper/lower casing
Most important: use consistent upper- or lowercasing within one file !
In general, in KDE the all-lowercase style is preferred."

2. kconfig/KF6ConfigMacros.cmake:149: Expression repeated inside
endforeach; better to use only endforeach() [readability/logic]:
"endforeach(_current_FILE)"

https://community.kde.org/Policies/CMake_Coding_Style#End_commands
says: "To make the code easier to read, use empty commands for
endforeach(), endif(), endfunction(), endmacro() and endwhile(). Also,
use empty else() commands. "
This is also recommended by the CMake project
https://cmake.org/cmake/help/latest/command/if.html says "Per legacy,
the else() and endif() commands admit an optional <condition>
argument. If used, it must be a verbatim repeat of the argument of the
opening if command.". And the fact that
https://cmake.org/cmake/help/latest/command/if.html#synopsis is
different from https://cmake.org/cmake/help/v3.10/command/if.html#synopsis

3. kcalc/CMakeLists.txt:183: [whitespace/indent]:
"   add_subdirectory( autotests )"

In this example file, most lines use 4 spaces indent, while this line
use 3 spaces indent.
https://community.kde.org/Policies/CMake_Coding_Style#Indentation says
"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. Do
not use tabs."
If in a file has exactly 50% of of the indented lines using 3 spaces
and 50% of indented lines use 4 spaces, we should, in the future, use
4 spaces, because at least cmakelint leans towards having files
indented with 2 or 4 spaces.

Reply via email to