CMake Templates
June 5, 2026 ยท View on GitHub
Concise CMake 3.31+ templates for C++ executables and libraries.
Setup
Prompt your AI assistant with:
Create a new [executable|header-only library|library] [with vcpkg] called [project name] from acdemiralp/cmake_templates and apply the setup steps from the repository readme.
Alternatively:
- Copy the desired template directory and rename it to your project name.
- Replace the project name in the
CMakeLists.txtwith your project name. - Optional: Add your dependencies to the
CMakeLists.txt. - Rename the include directory under
include/to your project name. - For libraries, update
source/library.cppto use your renamed export header and macro. - For templates with vcpkg:
- Replace the name in the
vcpkg.jsonwith your project name. - Optional: Add your dependencies to the
vcpkg.json. - Run
bootstrap.[bat|sh].
- Replace the name in the
Usage
- Configure :
cmake --preset ninja-multi. - Build :
cmake --build --preset [debug|release|relwithdebinfo]. - Test :
ctest --preset [debug|release|relwithdebinfo]. - Package :
cpack --preset [binary|source]. - Workflows :
cmake --workflow --preset [test|package].
Notes
Templates follow modern CMake best practices and the VCPKG CMake Style Guide, with the following exceptions: Alignment and glob are used, variable names are uppercase.