A modern C++ project template using CMake 3.25+ and CPM.cmake for dependency management, with out-of-the-box support for Windows, macOS, and Linux.
| Tool | Minimum version |
|---|---|
| CMake | 3.25 |
| C++ compiler | C++23-capable (MSVC 19.34+, GCC 13+, Clang 16+, AppleClang 15+) |
| Ninja (optional) | any recent version |
.
├── CMakeLists.txt # Main build script
├── CMakePresets.json # Platform presets (Windows / macOS / Linux)
├── cmake/ # Auto-downloaded CPM.cmake lives here
└── src/
└── main.cpp # Application entry point
Pick the preset that matches your platform:
| Platform | Preset name |
|---|---|
| Windows (Visual Studio 2022) | windows-msvc |
| Windows (Ninja + MSVC) | windows-ninja |
| Linux (GCC) | linux-gcc |
| Linux (Clang) | linux-clang |
| macOS (AppleClang) | macos-clang |
| Any platform – Debug | debug |
# Configure
cmake --preset linux-gcc # replace with your preset
# Build
cmake --build --preset linux-gccThe compiled binary is placed in build/<preset-name>/.
cmake -S . -B build
cmake --build buildCPM.cmake is downloaded automatically on the first CMake run.
Add packages inside CMakeLists.txt after the # Dependencies section:
CPMAddPackage("gh:fmtlib/fmt#11.0.2")
target_link_libraries(${PROJECT_NAME} PRIVATE fmt::fmt)- Windows –
UNICODE,_UNICODE,WIN32_LEAN_AND_MEAN, andNOMINMAXare defined automatically. MSVC warning level/W4is enabled. - macOS / Linux –
-Wall -Wextra -Wpedanticare passed to the compiler. compile_commands.jsonis always generated into the build directory for IDE/clangdsupport.
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
- CPM.cmake for dependency management