CMake
CMakePresets
Ninja
EditorConfig
VS Code
PCH
app
Feel free to pick any part or snippet you find interesting.
.editocronfig
- "must have", rules: file encoding, end of lines, trailing spaces, final newline, ...gitignore
- "must have"- CMake
CMakeLists.txt
- single-file build-gen description for the project<-- the most interesting part
CMakePresets.json
- define configurations forMSVC
GCC
Clang
(debug), used by CMake implicitly and CMakeLists.txt explicitly viacacheVariables
to configure the build
- project structure
src/
config.hpp
- (optional) precompiled header with project-wide c++ definesmain.cpp
- possible folders/files:
include/
,src/<int|internal>/
dep/
,doc/
,res/
,misc/
,misc/<cmake|script|other>
,(UN)LICNESE
,changelog.md
- possible tools:
Tests
,CI/CD
,Git Hooks
,Git Submodules
,Linters
,Package Managers
- VS Code - IDE
.vscode/c_cpp_properties.json
- configvscode-cpptools
: language server, ...vscode/extensions.json
- list of extensions used in the project.vscode/settings.json
- folder settings, works when opened as folder (not as workspace)./*.code-workspace
- user settings, overtakes.vscode/settings.json
"files.readonlyInclude":{
- prevent accidental editing"files.associations:{"
- prevent constant growth from opening C++ extension-less STL header files"cmake.parallelJobs": 4
-0
defaults to wrong6
on 4-threaded CPU and slows configuration (in my case)"files.trimTrailingWhitespace": false
- stop racing with EditorConfig extension
- std/c++_gnu++; (?)
Campare anything here: https://github.com/Challanger524/template-cpp/compare
Remark: I did not find any sane and useful C++ starting templates - they simply don't exist. For comparison, just take a look on what Golang community pulled out:
- Organizing a Go module - official layout guide, o-ff-i-c-i-a-l !!1
- https://github.com/golang-standards/project-layout - big detailed repo and layout showcase
- https://github.com/evrone/go-clean-template - same + readme contains pretty images, oh wow
Projects and libraries
Since there no useful templates outside - real projects are the only source of examples.
- https://github.com/nlohmann/json -
Lib
json
c++
readme.md
(very decent) - ...
https://www.reddit.com/r/cpp_questions/comments/n73n32/presenting_a_c_project_on_github_elegantly/
Templates examples and demos
- https://github.com/TheCherno/ProjectTemplate -
Premake
"Core/App" architecture
- https://github.com/edumentab/cpp-project-example -
CMake
JetBrains
GTest
- https://github.com/fnl/cpp-project-template -
CMake
(nested)gitmodules
Catch2
cxxopts
- https://github.com/erayaydin/cpp-structure -
GNU Make
project layout
- https://github.com/karvozavr/multi-module-cpp-project-example -
CMake
multi-project
Catch2
- https://github.com/jblort/cpp-project-template -
CMake
Conan
lib
+app
Catch2
- https://github.com/ssciwr/cpp-project-template -
CMake
CI/CD
Doxygen
Catch2
- https://github.com/Jamagas/CMake -
CMake
GTest
- https://github.com/pvanhoof/dir-examples - the most ugly project layout example on the net -
Meson
qmake
GNU Make
CMake
(4 levels of nestiness)