# CMake ## CMake Variables CMake variables can be defined and passed to CMake during builds. For example with Zephyr, building with a shield board uses a CMake variable to include the shield of the devicetree and Kconfigs in the build. When building for the [G1120B0MIPI](https://docs.zephyrproject.org/latest/boards/shields/g1120b0mipi/doc/index.html) display shield with command line, `-DSHIELD=g1120b0mipi` is added to the command for CMake. CMake variables can also be added in a VS Code project with the MCUXpresso extension. After creating/importing the project, open the project file `CMakePresets.json`. Add the variable to the `cacheVariables` group. In this example, the line `"SHIELD": "g1120b0mipi"` was added. The CMakePresets.json file includes different build configurations, typically a Debug and Release build configs. The CMake variables should be added to each build config that are needed. The image below shows adding the `SHIELD` variable to the `debug` build config. ![cmake-presets.json](./pictures/nxp-cmake-variable-json.png) Save the file, clean and build the project. Now the new CMake variable is included in the build. It is recommended to use the `CMakePresets.json` file when defining any additional CMake variables, this allows you to define different variables per build configuration as needed. `settings.json` is another file where CMake variables may be stored. To move the CMake variables to presets simply remove them from `settings.json` file and add them to `CMakePresets.json` under `cacheVariables`. ![cmake-settings.json](./pictures/nxp-settings-extra-cmake-args.png) ![cmake-presets.json-with-extra-args](./pictures/nxp-presets-extra-cmake-args.png) You can define additional CMake variables to the `CMakePresets.json` file using the UI by navigating to the Build Configurations section of your project. Choose the build configuration you want to modify, then add your CMake variables in the `CMake Extra Args` text field. ![extra-args-build-config-ui](./pictures/nxp-ui-extra-cmake-args.png)