# CMakePresets and location of source folder

**URL:** https://discourse.cmake.org/t/cmakepresets-and-location-of-source-folder/3118
**Category:** Development
**Created:** [April 12, 2021, 9:49am UTC](https://discourse.cmake.org/t/cmakepresets-and-location-of-source-folder/3118 "2021-04-12T09:49:08Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Kerstin\_Keller](https://discourse.cmake.org/user_avatar/discourse.cmake.org/kerstin_keller/32/180_2.png) [@Kerstin\_Keller](https://discourse.cmake.org/u/Kerstin_Keller)
#### Post date: [April 12, 2021, 9:49am UTC](https://discourse.cmake.org/t/cmakepresets-and-location-of-source-folder/3118/1 "2021-04-12T09:49:09Z")

</div>

According to the documentation, the new `CMakePresets.json` file needs to be located next to the main `CMakeLists.txt` file.

I now have the usecase, that I would like to generate those `CMakePresets.json` files (I am using Conan, I install Conan dependencies to given Prefix Paths for a given compiler, so I generate a `CMakePresets.json` file which contains all this information).  
However, since CMake requires this file to be placed next to the `CMakeLists.txt` file, I also generate a top level CMake file, which has a `add_subdirectory` to the original file.

Would it be possible that the `CMakePresets.json` file specifies (optionally) a source folder, if there is no `CMakeLists.txt` adjacent to it? Or is it too much of a special use case?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [April 12, 2021, 11:47am UTC](https://discourse.cmake.org/t/cmakepresets-and-location-of-source-folder/3118/2 "2021-04-12T11:47:58Z")

</div>

Cc: @kyle.edwards

---

<div class="post-metadata">

### Author: ![ligogeorge](https://discourse.cmake.org/user_avatar/discourse.cmake.org/ligogeorge/32/6164_2.png) [@ligogeorge](https://discourse.cmake.org/u/ligogeorge)
#### Post date: [July 1, 2026, 10:54am UTC](https://discourse.cmake.org/t/cmakepresets-and-location-of-source-folder/3118/3 "2026-07-01T10:54:02Z")

</div>

I am also interested in this feature, need to configure source directory per preset. Is there a way to do this ?

---

<div class="post-metadata">

### Author: ![vito.gamberini](https://discourse.cmake.org/user_avatar/discourse.cmake.org/vito.gamberini/32/4376_2.png) [@vito.gamberini](https://discourse.cmake.org/u/vito.gamberini)
#### Post date: [July 2, 2026, 1:41pm UTC](https://discourse.cmake.org/t/cmakepresets-and-location-of-source-folder/3118/4 "2026-07-02T13:41:47Z")

</div>

[See `--presets-file`](https://cmake.org/cmake/help/latest/manual/cmake.1.html#cmdoption-cmake-presets-file) for reading presets from an arbitrary file location

---

<div class="post-metadata">

### Author: ![ligogeorge](https://discourse.cmake.org/user_avatar/discourse.cmake.org/ligogeorge/32/6164_2.png) [@ligogeorge](https://discourse.cmake.org/u/ligogeorge)
#### Post date: [July 3, 2026, 6:23am UTC](https://discourse.cmake.org/t/cmakepresets-and-location-of-source-folder/3118/5 "2026-07-03T06:23:00Z")

</div>

Thanks for the response. But actually we need to configure the `sourceDirectory`, we are using Zephyr, which needs specific source directory for the [sysbuild](https://docs.zephyrproject.org/latest/build/sysbuild/index.html) to work. `CMakePresets.json` location is same for all targets, but for zephyr based targets we need to switch `sourceDirectory`.

---

<div class="post-metadata">

### Author: ![vito.gamberini](https://discourse.cmake.org/user_avatar/discourse.cmake.org/vito.gamberini/32/4376_2.png) [@vito.gamberini](https://discourse.cmake.org/u/vito.gamberini)
#### Post date: [July 6, 2026, 7:26am UTC](https://discourse.cmake.org/t/cmakepresets-and-location-of-source-folder/3118/6 "2026-07-06T07:26:33Z")

</div>

`sourceDir` is always the path to the project source directory. It’s unclear to me what the meaning of `sourceDir` would be if it weren’t the path to the project source directory.

I don’t foresee this ever being a configurable value.

You can use the same CMakePreset for all projects with `--presets-file`, which allows you to use a preset file from an arbitrary location.
