This CMake/C++ template project gives me a good starting point for f.e. GPU/Graphics programming. For everything close to hardware ... .
For the official docs follow this link.
About The Project โข Getting Started โข License โข Literature
Table of Contents
This project is dedicated to compiling a comprehensive collection of best practices for C++ development using CMake. It serves as a definitive guide for starting new C++ projects, providing insights into optimal project setup, modern CMake techniques, and efficient workflows. The repository includes examples, templates, and detailed instructions to help developers of all levels adopt industry standards and improve their project configuration and build processes.
Frequently tested under
- windows server 2025 x64 Clang 20.1.0 and MSVC
- ubuntu 24.04 x64 Clang 18.1.3
- ubuntu 24.04 ARM Clang 18.1.3
Category | Feature | Implement Status |
---|---|---|
Build System | CMake > 4.0 | โ๏ธ |
Performance | Performance Benchmark | โ๏ธ |
Platform Support | Linux/Windows support | โ๏ธ |
Compiler Support | Clang/GNU/MSVC support | โ๏ธ |
Legend:
- โ๏ธ - completed
- ๐ถ - in progress
- โ - not started
This enumeration also includes submodules.
C++23 or higher required.
C17 or higher required.
CMake 4.0.0 or higher required.
- Clone the repo
git clone --recurse-submodules [email protected]:Kataglyphis/Kataglyphis-CMakeTemplate.git
NOTE: In case you forgot the flag --recurse run the following command
afterwards.git submodule update --init --recursive
- Optional: Using the newest clang compiler. Install via apt. See here:
- Optional: Run
scripts/prepare_tooling.sh
for preparing important dev tools. - Then build your solution with [CMAKE] (https://cmake.org/)
Here the recommended way over command line after cloning the repo:
NOTE: Here we use CmakePresets to simplify things. Consider using it too or just build on a common way.
For now the features in Rust are experimental. If you want to use them install
Rust and set RUST_FEATURES=ON
on your CMake build.
(for clarity: Assumption you are in the dir you have cloned the repo into)
$ mkdir build ; cd build
# enlisting all available presets
$ cmake --list-presets=all ../
$ cmake --preset <configurePreset-name> ../
$ cmake --build --preset <buildPreset-name> .
- Do not forget to upgrade the cxxbridge from time to time:
cargo install cxxbridge-cmd
I have four tests suites.
-
Compilation Test Suite: This suite gets executed every compilation step. This ensures the very most important functionality is correct before every compilation.
-
Commit Test Suite: This gets executed on every push. More expensive tests are allowed :)
-
Perf test suite: It is all about measurements of performance. We are C++ tho!
-
Fuzz testing suite
Linux only
- Step:
sudo apt-get install google-perftools libgoogle-perftools-dev graphviz
####### only if go is not installed already
wget https://go.dev/dl/go1.24.3.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.24.3.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
source ~/.bashrc
# to see if everything works
go version
####### go on with this step if go already installed
go install github.com/google/pprof@latest # if you want to use latest Go-based pprof
export PATH="$PATH:$HOME/go/bin"
source ~/.bashrc # or source ~/.zshrc
- Step: Run actual profiling and look into results:
LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libprofiler.so CPUPROFILE=profile.prof ./build/KataglyphisCppProject
pprof -http=:8080 ./build/KataglyphisCppProject profile.prof
sudo apt install valgrind kcachegrind
# build in debug for readable information
valgrind --tool=callgrind ./build/KataglyphisCppProject
sudo apt install linux-tools-$(uname -r)
perf record ./build/KataglyphisCppProject
clang --analyze --output-format html $(find Src -name '*.cpp' -o -name '*.cc')
scan-build cmake --build .
clang-tidy -p=./build/compile_commands.json $(find Src -name '*.cpp' -o -name '*.cc')
uv venv
source .venv/bin/activate
pip install -v -e .
cmake-format -c ./.cmake-format.yaml -i $(find cmake -name '*.cmake' -o -name 'CMakeLists.txt')
clang-format -i $(find include -name "*.cpp" -or -name "*.h" -or -name "*.hpp")
Build the docs
uv venv
source .venv/bin/activate
pip install -r requirements.txt
cd docs
make html
Upcoming :)
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Jonas Heinle - @Cataglyphis_ - [email protected]
Some very helpful literature, tutorials, etc.
Rust
CMake/C++