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?
2 Likes
I am also interested in this feature, need to configure source directory per preset. Is there a way to do this ?
See --presets-file for reading presets from an arbitrary file location
Thanks for the response. But actually we need to configure the sourceDirectory, we are using Zephyr, which needs specific source directory for the sysbuild to work. CMakePresets.json location is same for all targets, but for zephyr based targets we need to switch sourceDirectory.
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.