Search code examples
cmakecmake-presets

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


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?


Solution

  • 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{}.