CMake presets build options
CMake presets can have specific build preset option for particular build tools. This CMakePresets.json shows example build presets for Ninja. The preset name “ninja” in this example is arbitrary. As usual, the presets help avoid copying script parameters and the possibility of typos in duplicated script code, whether for CI or developers themselves.
For example, to have ninja “explain” why a target is dirty:
cmake --build --preset explain
{
"version": 2,
"configurePresets": [
{
"name": "ninja",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build"
}
],
"buildPresets":[
{
"name": "explain",
"configurePreset": "ninja",
"nativeToolOptions": ["-d", "explain"]
},
{
"name": "keep",
"configurePreset": "ninja",
"nativeToolOptions": ["-d", "keeprsp", "-d", "keepdepfile"]
},
{
"name": "stats",
"configurePreset": "ninja",
"nativeToolOptions": ["-d", "stats"]
}
]
}