Gyorgy Szing | 5e429cb | 2019-12-03 20:39:55 +0100 | [diff] [blame^] | 1 | Coding Style & Guidelines |
| 2 | ========================= |
| 3 | |
| 4 | The following sections contain |TFACMF| coding guidelines. They are continually |
| 5 | evolving and should not be considered "set in stone". Feel free to question them |
| 6 | and provide feedback. |
| 7 | |
| 8 | Rules |
| 9 | ----- |
| 10 | |
| 11 | #. CMake file names use `CamelCase`_ formating. |
| 12 | #. Indent with tabs and otherwise use spaces. Use 4 spaces for tab size. |
| 13 | #. Use LF as line end in CMake files. |
| 14 | #. Remove trailing whitespace. |
| 15 | #. When complicated functionality is needed prefer CMake scripting over |
| 16 | other languages. |
| 17 | #. Prefix local variables with `_`. |
| 18 | #. Use functions to prevent global name-space pollution. |
| 19 | #. Use `snake_case`_ for function and variable names. |
| 20 | #. Use the ``include_guard()`` CMake function when creating new modules, to |
| 21 | prevent multiple inclusion. |
| 22 | #. Use self contained modules, i.e. include direct dependencies of the module. |
| 23 | #. Use the Sphinx CMake domain for in-line documentation of CMake scripts. |
| 24 | For details please refer to the `CMake Documentation`_. |
| 25 | |
| 26 | .. todo:: Explain CMake return values and parent scope concept in more detail. |
| 27 | |
| 28 | -------------- |
| 29 | |
| 30 | .. _`CamelCase`: https://hu.wikipedia.org/wiki/CamelCase |
| 31 | .. _`snake_case`: https://en.wikipedia.org/wiki/Snake_case |
| 32 | .. _`CMake Documentation`: https://github.com/Kitware/CMake/blob/master/Help/dev/documentation.rst |
| 33 | |
| 34 | *Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.* |
| 35 | |
| 36 | SPDX-License-Identifier: BSD-3-Clause |