CMake Presets are a way to configure and share CMake options using two files:
CMakePresets.json for project-wise builds. This file can be shared via VCS.
CMakeUserPresets.json for developers' own local builds. This file should not be checked into VCS.
Both CMakePresets.json and CMakeUserPresets.json have the same format and should be located in the project's root directory.
note
CLion supports Presets versions 2-6 and only configure and build presets.
CMake Profiles have many settings in common with CMake Presets and are also shareable via VCS. The major difference is that profiles reference CLion toolchains, which contain information that is not present and not needed in CMake presets (like the debugger or environment settings).
Presets import
On project opening, CLion detects all build and configure presets in CMakePresets.json and CMakeUserPresets.json files under the project root. By default, all of them are loaded automatically into CMake profiles in read-only mode.
tip
In case you don't want the presets to be converted into CMake profiles, or if you want to exclude configure or build profiles, go to Settings | Advanced Settings and use the Automatically import CMake Presets switcher:
To view the loaded presets, go to Settings | Build, Execution, Deployment | CMake or use the View link in the notification dialog:
All new presets are disabled by default, unless you have already loaded and enabled them before (CLion matches them by name).
All previously loaded presets are removed if they are not present in the CMakePresets.json or CMakeUserPresets.json files.
You can also load presets for an already opened project.
Call Help | Find Action (CtrlShift0A) and search for Load CMake Presets.
CLion will show a popup with a list of the existing build presets:
Select the preset and press Enter.
You can select several entries by holding Ctrl or Shift. CLion will load all the selected presets.
Similarly to the case of opening a project, the presets you load manually are imported into CMake profiles in read-only mode. You can find them in Settings | Build, Execution, Deployment | CMake.
Enable a Presets profile
Go to Settings | Build, Execution, Deployment | CMake.
Select the desired profile and set the Enable profile checkbox:
tip
To build your project with the enabled profile, select it in the configuration switcher and build the configuration or call one of the available build actions. See Build with a profile.
Editing Presets
There are two options you can use to edit the imported presets:
As a result, the Clang10 toolchain will be assigned to the loaded preset:
On Windows, if you are working with the MSVC toolchain, the architecture and toolset properties from the configure preset will be fetched to CMake options as well:
Condition support
CLion supports the condition field in the CMakePresets.json and CMakeUserPresets.json files to filter presets. Note that only the equals and notEquals types are supported.
Here is an example of how to filter a preset by platform:
{"name":"windows-only","inherits":"default","displayName":"Windows-only configuration","description":"This build is only available on Windows","condition":{"type":"equals","lhs":"${hostSystemName}","rhs":"Windows"}}
After you configure filtering by platform, the corresponding preset will only appear in your preset profile list on the platform for which it is enabled.
Our website uses some cookies and records your IP address for the purposes of accessibility, security, and managing your access to the telecommunication network. You can disable data collection and cookies by changing your browser settings, but it may affect how this website functions. Learn more.
With your consent, JetBrains may also use cookies and your IP address to collect individual statistics and provide you with personalized offers and ads subject to the Privacy Notice and the Terms of Use. JetBrains may use third-party services for this purpose. You can adjust or withdraw your consent at any time by visiting the Opt-Out page.