# Can I specify -S via CMakePresets.json?

**URL:** https://discourse.cmake.org/t/can-i-specify-s-via-cmakepresets-json/6522
**Category:** Usage
**Created:** [September 19, 2022, 10:39pm UTC](https://discourse.cmake.org/t/can-i-specify-s-via-cmakepresets-json/6522 "2022-09-19T22:39:48Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![dwarwick](https://discourse.cmake.org/user_avatar/discourse.cmake.org/dwarwick/32/2298_2.png) [@dwarwick](https://discourse.cmake.org/u/dwarwick)
#### Post date: [September 19, 2022, 10:39pm UTC](https://discourse.cmake.org/t/can-i-specify-s-via-cmakepresets-json/6522/1 "2022-09-19T22:39:48Z")

</div>

Our homebrew scripts to build our project look like

```auto
cmake -S path/to/project_dir -G Ninja -etc

```

We are trying to convert to CMakePresets.json, but the only thing preventing that is the first argument above – the `-S` argument. Visual Studio runs cmake in weird places, so we would like to override it to something sensible, or else CMAKE\_CURRENT\_SOURCE\_DIR/etc get busted. I have not been able to find somewhere to override this in the CMakePresets.json spec. Is it unsupported?

---

<div class="post-metadata">

### Author: ![scivision](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/a87d85/32.png) [@scivision](https://discourse.cmake.org/u/scivision)
#### Post date: [September 21, 2022, 2:54am UTC](https://discourse.cmake.org/t/can-i-specify-s-via-cmakepresets-json/6522/2 "2022-09-21T02:54:27Z")

</div>

Is the issue that you wish to omit the `-S` parameter and set `sourceDir` in a CMakePresets.json in the current working directory? I don’t think that’s possible.

The buildPreset and testPreset require the current working directory to be the source directory where CMakePresets.json is. There are multiple open CMake issues about this, the most recent is: [https://gitlab.kitware.com/cmake/cmake/-/issues/23982](https://gitlab.kitware.com/cmake/cmake/-/issues/23982)

In short, to use presets to configure, build, and test currently require CMake to be executed from the top-level project directory where CMakePresets.json is to the best of my knowledge. I also would like to be able to execute CMake from arbitrary CWD and use presets, but I think that can’t be done yet.

---

<div class="post-metadata">

### Author: ![dwarwick](https://discourse.cmake.org/user_avatar/discourse.cmake.org/dwarwick/32/2298_2.png) [@dwarwick](https://discourse.cmake.org/u/dwarwick)
#### Post date: [September 21, 2022, 5:48am UTC](https://discourse.cmake.org/t/can-i-specify-s-via-cmakepresets-json/6522/3 "2022-09-21T05:48:57Z")

</div>

> [@scivision](#):
>
> The buildPreset and testPreset **require the current working directory to be the source directory where CMakePresets.json is.**

VS is blatantly violating that then. It wants to run it with the source directory in the build directory.
