Why is it disallowed for project preset to inherit user preset?

Hi guys,

A little bit of context before the question: I’ve been using some routine for quite a while to acknowledge some user specific needs. For example, I need Boost_DIR to be set on some systems and some other variables helping in finding configs. To achieve that I use some LocalConfig.cmake which is not stored in git but gets created by the local user and then it gets included like include(LocalConfig.cmake) in the root CMake file. It works and gives me what I need but recently I found out about presets and decided that they look like the very thing I can replace my local config with.

So I tried to convert my solution to the preset-based one and here what I’ve come up with:
CMakePresets.json:

{
  "version": 3,
  "configurePresets": [
    {
      "name": "Common",
      "description": "Common values for other configurations",
      "hidden": true,
      "inherits": "LocalConfig"
    },
  ]
}

And CMakeUserPresets.json:

{
    "version": 3,
    "configurePresets": [
        {
            "name": "LocalConfig",
            "hidden": true,
            "cacheVariables": {
                "Boost_DIR": "Path/To/Boost/Config"
            }
        }
    ]
}

But it doesn’t work because:

CMake Error: Could not read presets from PATH: Project preset inherits from user preset

So my question is: why can’t I inherit it? And is there some other way for a local user to extend global presets? Maybe I’m doing everything wrong and there are other ways how I can achieve the same behavior? Or I misunderstand the presets and they are not supposed to help in my case?

@kyle.edwards

Note that CMakePresets.json is a file that is shared with the entire development team. You really don’t want to inherit anything from some random person’s CMakeUserPresets.json, because that’s a private file that he / she doesn’t share with anybody. This would not work well for this single developer if only for the error message, because both files are available. As for the rest of the team the configure step fails anyways because LocalConfig is missing.

I don’t inherit anything it is a person building does and it is their file not a random one. Which is exactly the point.

And that might be just the desired behavior or it might not fail and just ignore the non-exstent preset if you try to inherit from it.

Anyway, I’m not really interested in this question anymore because after some research I found out that I can’t do what I need with current presets. Created a different proposal on gitlab.

Note that in the example you provide above Common inherits from LocalConfig. You do not want to do this. I understand that this is not random but from the tooling perspective Common should not be affected by LocalConfig. Note that presets take advantage from all of its inheritance by default but have the power to override almost all fields to their desire.

Yes it should. It is exactly my point. I need to add local settings to all global presets and there is no easier way (potentially, because right now there is simply no way at all) than overriding some Common preset’s values with something only a local user might know.

If you can’t affect global presets with some user specific values it narrows its usage massively. And there is no point in having it that way.

Currently, it is only possible to add local settings to all global presets without affecting Common. This is achieved by overriding some (inherited) Common preset’s values with something only a local user might know.

If you can affect global presets with some user specific values it is impossible to use them globally.