Overview
CMake presets provide predefined build configurations inCMakePresets.json. They simplify building by bundling common options into named configurations.
Using Presets
Use presets with the--preset flag:
The build directory name includes the preset name:
build-<preset-name>Available Presets
Linux Presets
- GCC
x64-linux-gcc-debugDebug build with GCC compilerx64-linux-gcc-releaseRelease build with GCC compilerx64-linux-gcc-reldbgRelease with debug info (RelWithDebInfo)x64-linux-gcc+static-releaseStatic release build with GCC
Windows Presets
- LLVM/Clang (x64)
- LLVM/Clang (ARM64)
- MSVC
- SYCL (Intel GPU)
- Vulkan
x64-windows-llvm-debugDebug build with LLVM/Clangx64-windows-llvm-releaseRelease build with LLVM/Clangx64-windows-llvm-reldbgRelease with debug infox64-windows-llvm+static-releaseStatic release build
macOS Presets
arm64-apple-clang-debugListing Available Presets
To see all available presets:Preset Architecture
Base Presets
Presets inherit from hidden base configurations:-
base: Common settings for all presets
- Generator: Ninja
- Build directory:
build-${presetName} - Export compile commands: ON
- Install RPATH:
$ORIGIN;$ORIGIN/..
-
sycl-base: Base for SYCL builds
- Compilers: icx (C++), cl (C)
- SYCL enabled
Build Type Presets (Hidden)
These are combined with other presets:- debug:
CMAKE_BUILD_TYPE=Debug - release:
CMAKE_BUILD_TYPE=Release - reldbg:
CMAKE_BUILD_TYPE=RelWithDebInfo - static:
GGML_STATIC=ON
Platform Presets (Hidden)
- x64-windows-llvm: Uses x64-windows-llvm.cmake toolchain
- arm64-windows-llvm: Uses arm64-windows-llvm.cmake toolchain
- arm64-apple-clang: Uses arm64-apple-clang.cmake toolchain
- x64-linux-gcc: Uses GCC compiler
Customizing Presets
Adding CMake Options to Presets
You can add additional options when using presets:Windows ARM with OpenMP disabled
Linux with CUDA
Creating Custom Presets
You can create aCMakeUserPresets.json file (git-ignored) for personal presets:
CMakeUserPresets.json
Preset Structure Reference
Each preset inCMakePresets.json contains:
Example from
CMakePresets.json:
- Uses Ninja generator (from
base) - Uses LLVM toolchain (from
x64-windows-llvm) - Sets Release build type (from
release)
Common Workflows
Development Cycle
1
Choose debug preset
Select appropriate debug preset for your platform:
2
Build
3
Test changes
4
Rebuild after changes
CMake automatically detects changes:
Release Build
1
Clean previous builds (optional)
2
Configure release preset
3
Build with parallel jobs
4
Install (optional)
Multi-Configuration Build
Build multiple configurations simultaneously:Platform-Specific Notes
Windows
Use Developer Command Prompt for Visual Studio when using MSVC or LLVM presets.
macOS
Apple Silicon (M1/M2/M3) builds:Metal is enabled by default on macOS. The preset does not disable it.
Linux
For production deployments:Troubleshooting
Preset Not Found
Wrong Generator
If Ninja is not installed:Build Directory Exists
Best Practices
- Use presets for consistency: Ensures reproducible builds across team members
- Create user presets: Use
CMakeUserPresets.jsonfor personal configurations - Version control: Commit
CMakePresets.json, ignoreCMakeUserPresets.json - Name conventions: Follow existing naming patterns for clarity
- Build isolation: Each preset uses separate build directory
Further Reading
- CMake Build Options - Detailed option reference
- Building from Source - Complete build guide
- CMake Presets Documentation - Official CMake docs

