# Out of source CMake preset file

**URL:** https://discourse.cmake.org/t/out-of-source-cmake-preset-file/8879
**Category:** Usage
**Created:** [September 4, 2023, 12:52pm UTC](https://discourse.cmake.org/t/out-of-source-cmake-preset-file/8879 "2023-09-04T12:52:34Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![fwh](https://discourse.cmake.org/user_avatar/discourse.cmake.org/fwh/32/3780_2.png) [@fwh](https://discourse.cmake.org/u/fwh)
#### Post date: [September 4, 2023, 12:52pm UTC](https://discourse.cmake.org/t/out-of-source-cmake-preset-file/8879/1 "2023-09-04T12:52:34Z")

</div>

Hi,

I am looking for some advice regarding the use of preset files: `CMakePresets.json`

I am building a 3rd party library for different platforms using a different set of variables for each platform and I want to use CMake presets for maintaining this setup.

How can I make CMake consume a `CMakePresets.json` outside of the 3rd party library codebase?

- my-repo
  - CMakePresets.json
  - 3rd-party-library
    - CMakeLists.txt

I’d like to be able to run something like

`cmake --preset=my-config -B build-folder -S 3rd-party-library`

However if I do that then cmake complains that it could not find the `CMakePresets.json` file. I am assuming it only searches the `3rd-party-library` directory.

What is the best way to achieve my goal?

Regards,  
Frederik

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [September 6, 2023, 9:33pm UTC](https://discourse.cmake.org/t/out-of-source-cmake-preset-file/8879/2 "2023-09-06T21:33:25Z")

</div>

I’m pretty sure that isn’t supported. My understanding is that the `CMakePresets.json` file has to be at the top of the source tree. @kyle.edwards may have more thoughts on whether other scenarios like the one you describe could be supported.

---

<div class="post-metadata">

### Author: ![kyle.edwards](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/65b543/32.png) [@kyle.edwards](https://discourse.cmake.org/u/kyle.edwards)
#### Post date: [September 6, 2023, 9:38pm UTC](https://discourse.cmake.org/t/out-of-source-cmake-preset-file/8879/3 "2023-09-06T21:38:36Z")

</div>

If you don’t plan on sharing your presets file with anyone, if it will only live on your local machine, I’d suggest putting it in the 3rd party library folder as `CMakeUserPresets.json`.

If you plan on sharing it, I’d suggest forking the 3rd party repo and adding `CMakePresets.json` to it.

---

<div class="post-metadata">

### Author: ![fwh](https://discourse.cmake.org/user_avatar/discourse.cmake.org/fwh/32/3780_2.png) [@fwh](https://discourse.cmake.org/u/fwh)
#### Post date: [September 15, 2023, 6:23am UTC](https://discourse.cmake.org/t/out-of-source-cmake-preset-file/8879/4 "2023-09-15T06:23:40Z")

</div>

Okay, I still think it would be nice to avoid maintaining a fork for just this particular purpose. Thanks for clarifying!
