# Set environment variables for all CMake Presets

**URL:** https://discourse.cmake.org/t/set-environment-variables-for-all-cmake-presets/7116
**Category:** Code
**Created:** [December 22, 2022, 1:31pm UTC](https://discourse.cmake.org/t/set-environment-variables-for-all-cmake-presets/7116 "2022-12-22T13:31:16Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Leon0402](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/l/ccd318/32.png) [@Leon0402](https://discourse.cmake.org/u/Leon0402)
#### Post date: [December 22, 2022, 1:31pm UTC](https://discourse.cmake.org/t/set-environment-variables-for-all-cmake-presets/7116/1 "2022-12-22T13:31:17Z")

</div>

Hi,

is it somehow possible to define environment variables for all existing preset.

The use case I’m thinking off is the following. Say I have a project with CMakePresets with a lot of presents for different compilers, generators.

On my machine now I do have library X which is not found automatically. Thus, I want to set CMAKE\_PREFIX\_PATH or something on my machine. Perfekt for this is a CMakeUserPresets. But the problem I see so far is that I have to inherit an existing preset and enhance it. So what I’m currently do i just define a “default” preset, which uses some configurations like Make + Clang Compiler in Debug Mode and set the cmake variable for this target. But it would be more convenient to define a user option, which is applied automatically to all presets in CMakePresets.

Is something like this possibly or would it be a good idea to implement perhaps?

---

<div class="post-metadata">

### Author: ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)
#### Post date: [August 15, 2023, 1:57pm UTC](https://discourse.cmake.org/t/set-environment-variables-for-all-cmake-presets/7116/2 "2023-08-15T13:57:28Z")

</div>

CMAKE\_PREFIX\_PATH is a [cmake-env-variables](https://cmake.org/cmake/help/latest/manual/cmake-env-variables.7.html)?
