problem of visibility with cmake-presets inheritance

237 Views Asked by At

cmake-presets supports inheritance. That is nice, providing that the parent preset is visible, but not work otherwise. Taking for example with preset1.json:

{
  "version": 5,
  "configurePresets": [
   {
    "name": "base_preset"
   }
}

preset2.json:

{
  "version": 5,
  "configurePresets": [
   {
    "name": "child_preset",
    "inherits": [
        "base_preset"
     ]
   }
}

and CMakePresets.json:

{
  "version": 5,
  "include": [
       "preset1.json",
       "preset2.json"
  ]
}

The inherited preset does not work because base_preset is unreachable. Is it a bug or intended behavior?

1

There are 1 best solutions below

0
On

Seems it's intended behavior.

You assume that the inclusion order in CMakePresets.json would also cover the declaration and inheritance order of presets, but instead each file needs to include it's inherited presets.

In your case preset2.json needs to include preset1.json to have base_preset visible.

Quoting Kyle Edwards (Jun '23) on "CMakePresets: Include Behavior":

When one preset points to another, either through inheritance or as a build/test/package preset associated with a configure preset, the file containing the build/test/package preset must include the file containing the configure preset.