Using presets defined in a project
The configuration of projects can become a complex task when we need to be specific about elements such as cache variables, chosen generators, and more—especially when there are multiple ways to build our project. This is where presets come in handy. Instead of memorizing command-line arguments or writing shell scripts to execute cmake
with different arguments, we can create a preset file and store the required configuration in the project itself.
CMake utilizes two optional files to store project presets:
CMakePresets.json
: Official presets delivered by project authors.CMakeUserPresets.json
: Dedicated to users who wish to add custom presets to the project. Projects should add this file to the VCS ignore list to ensure that custom settings don’t inadvertently get shared in the repository.
Preset files must be placed in the top directory of the project for CMake to recognize them. Each preset file can define...