Skip to content
All projects

2025

cmake-boilerplate: a C++20 template for GPU projects

The CMake layout I start C++ and GPU projects from: toolchain selection, sanitizers, ccache, clang-format and clang-tidy, CPM-managed dependencies, and a CUDA or HIP runtime chosen at configure time.

A template, not an application: the repository I clone a new C++ project from so the build system is already right.

What it sets up

The top-level CMakeLists.txt exposes cache variables for the toolchain (GNU, Clang, or MSVC), AddressSanitizer and ThreadSanitizer, ccache, and CPack packaging, and builds a static library plus an executable. Dependencies are declared one file each under cmake/modules/ through CPM.cmake; sixteen are included, from GLFW, GLM, and ImGui to Boost, CGAL, spdlog, ZeroMQ, OpenSSL, FFmpeg, and OpenCV with CUDA. cmake/gpu.cmake picks a CUDA or HIP runtime and target architecture at configure time; HIP on AMD stops with a fatal error rather than misconfiguring silently.

src/ has one small example per dependency, so a build proves each module resolves; a vector-add kernel in both cuda.cu and hip.cu that main.cpp runs; and two reusable pieces: CThreadBase<T>, a heartbeat thread using C++20 concepts, and CQueue, a thread-safe, optionally bounded blocking queue with its own API note.

Scale

Two public commits from a squashed history. MIT licensed. No CI of its own, since it is the thing other projects add CI to.