How to save a build configuration as a preset

nRF Connect for VS Code

tags
nRF Connect for VS Code

You can save a build configuration you have made for your application as a CMake Preset, which stores the specific settings required for the build. Saving a preset stores this information in a CMakePresets.json file. This allows you to share build configurations when working with others.

To save a build configuration:

  1. Hover your mouse over the build directory.
  2. Click the menu icon More Actions > Save Configuration As Preset.

    Save Configuration As Preset

The current build configuration is saved to the CMakePresets.json file, which opens in the Editor after completing the action. For example:

{
    "version": 2,
    "cmakeMinimumRequired": {
        "major": 3,
        "minor": 20
    },
    "configurePresets": [
        {
            "name": "build",
            "displayName": "Build for nRF54l15 DK nRF54l15 Application",
            "generator": "Ninja",
            "binaryDir": "${sourceDir}/build",
            "cacheVariables": {
                "BOARD": "nrf54l15dk/nrf54l15/cpuapp",
                "DEBUG_THREAD_INFO": true,
                "CONFIG_DEBUG_THREAD_INFO": true,
                "hello_worlds_3_DEBUG_THREAD_INFO": true
            }
        }
    ]
}

The name of the preset corresponds to the displayName field in CMakePresets.json.

Alternatively, you can run nRF Connect: Save Configuration as Preset from the Command Palette, which also saves the build configuration to the CMakePresets.json file.