cpp-best-practices / cpp-best-practices/cmake_template

Some suggestions about devcontainer.json, clang-tidy, cmake-format, and ubuntu jimmy.

Open
#13 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
CMake
Stars
1.8k
Forks
204
PR merge metrics
No merged PRs in 30d

Description

Hello @lefticus. I admire your work. I have some suggestions and we can discuss about them and then I can create some PRs if they turn out to be good :

In `devcontainer.json`, add these settings for better automatically checking for Clang errors. VSCode shows nicely the problems and underlines the problematics line.
```
"C_Cpp.codeAnalysis.runAutomatically": true, // For automatically run code analysis on save
"C_Cpp.codeAnalysis.clangTidy.enabled": true, // Clang tidy checks are included when it is run code analysis
"C_Cpp.codeAnalysis.exclude": { // Exclude checking in out directory (using presets). Maybe need some other folders too.
"${workspaceFolder}/out/**": true
```

And add extension:
` "cheshirekow.cmake-format" // For automatically run formating cmake files on save`
This extension must have installed `cmake-format`. Because of this, we need to add in `Dockerfile`:
`RUN python3 -m pip install cmake_format`

In .clang-tidy I always like to add CheckOptions for example:
```
CheckOptions:
- { key: readability-identifier-naming.NamespaceCase, value: lower_case }
- { key: readability-identifier-naming.ClassCase, value: CamelCase }
- { key: readability-identifier-naming.StructCase, value: CamelCase }
- { key: readability-identifier-naming.TemplateParameterCase, value: CamelCase }
- { key: readability-identifier-naming.FunctionCase, value: CamelCase }
- { key: readability-identifier-naming.VariableCase, value: lower_case }
- { key: readability-identifier-naming.PrivateMemberSuffix, value: _ }
- { key: readability-identifier-naming.ProtectedMemberSuffix, value: _ }
- { key: readability-identifier-naming.MacroDefinitionCase, value: UPPER_CASE }
- { key: readability-identifier-naming.EnumConstantCase, value: CamelCase }
- { key: readability-identifier-naming.EnumConstantPrefix, value: k }
- { key: readability-identifier-naming.ConstexprVariableCase, value: CamelCase }
- { key: readability-identifier-naming.ConstexprVariablePrefix, value: k }
- { key: readability-identifier-naming.GlobalConstantCase, value: CamelCase }
- { key: readability-identifier-naming.GlobalConstantPrefix, value: k }
- { key: readability-identifier-naming.MemberConstantCase, value: CamelCase }
- { key: readability-identifier-naming.MemberConstantPrefix, value: k }
- { key: readability-identifier-naming.StaticConstantCase, value: CamelCase }
- { key: readability-identifier-naming.StaticConstantPrefix, value: k }
```
This force developers to use the same naming conventions. What do you think?

One more suggestion is to support the new ubuntu Jimmy.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.