Can I change the name and/or the path of the CMakePresets.json file?

72 Views Asked by At

The introduction of CMake presets is great, and I am trying to use it for a big project on multiplatform multiconfiguration project. The introduction of include in version 4 made that a bit easier and I am using the include strongly. since the include allows different names other than CMakePresets.json I chose to name the preset files for the different configuration meaningful names, however it would be great if I can have the main CMake presets file have also a different name, that way I can use the included JSON files for different purposes. However, so far I cant find if that is possible, so is it possible to use a presets file having a name different from CMakePresets.json?

2

There are 2 best solutions below

0
On BEST ANSWER

No you can't- at least- not at the time of this writing. It's hardcoded. See cmCMakePresetsGraph::GetFilename in https://github.com/Kitware/CMake/blob/master/Source/cmCMakePresetsGraph.cxx.

FYI that if you're doing stuff with preset includes and you have a bunch of different presets for inclusion for different things, includes support macro expansion since preset version 7, but only for $penv{}.

0
On

While as the answer above indicates, one cannot. I found that using includes makes it very helpful for very big projects. Therefore, it would go like this, make a cmakepresets file with the file name you are interested in for each configuration you want and then just include them in the CMakePresets file. This is particularly important for big projects.