Error: @4,9: Invalid "include" field in CMake Preset

${hostSystemName}

The name of the host operating system. Contains the same value as CMAKE_HOST_SYSTEM_NAME. This is allowed in preset files specifying version 3 or above.

I am wondering this fails:

{
    "version": 7,
    "include": [
        "CMake${hostSystemName}Presets.json"
    ],
    "buildPresets": [
        {
            "name": "default",
            "configurePreset": "default"
        }
    ],
    "testPresets": [
        {
            "name": "default",
            "configurePreset": "default",
            "output": {
                "outputOnFailure": true
            },
            "execution": {
                "noTestsAction": "error",
                "stopOnFailure": true
            }
        }
    ],
    "packagePresets": [
        {
            "name": "default",
            "configurePreset": "default",
            "generators": [
                "TGZ"
            ]
        }
    ],
    "workflowPresets": [
        {
            "name": "default",
            "steps": [
                {
                    "type": "configure",
                    "name": "default"
                },
                {
                    "type": "build",
                    "name": "default"
                },
                {
                    "type": "test",
                    "name": "default"
                },
                {
                    "type": "package",
                    "name": "default"
                }
            ]
        }
    ]
}

with cmake version 3.29.20240402-gf8ba5b1 works fine. :grinning:

fixed with MR#9108

for current cmake version 3.28…3.29 see https://gitlab.kitware.com/cmake/cmake/-/issues/25654

@ben.boeckel but this is still not valid?

{
  "version": 9,
  "cmakeMinimumRequired": {
    "major": 3,
    "minor": 29,
    "patch": 0
  },
  "configurePresets": [
    {
      "name": "dev",
      "generator": "Ninja",
      "binaryDir": "${sourceDir}/build/dev",
      "inherits": ["dev-mode", "vcpkg", "ci-${hostSystemName}"],
      "cacheVariables": {
        "CMAKE_BUILD_TYPE": "Debug"
      },
      "environment": {
          "VCPKG_ROOT": "$env{HOME}/vcpkg"
      }
    }
  ],
  "buildPresets": [
    {
      "name": "dev",
      "configurePreset": "dev",
      "configuration": "Debug"
    }
  ],
  "testPresets": [
    {
      "name": "dev",
      "configurePreset": "dev",
      "configuration": "Debug",
      "output": {
        "outputOnFailure": true
      }
    }
  ]
}

No idea? What’s the issue here?

both results in invalid preset!

@kyle.edwards Thoughts?

I’m pretty sure the inherits field does not support variable expansion.

That is the problem!

I don’t know if there’s anything fundamental about it, but if not, a feature request would be the way to go.

bash-5.2$ cmake --list-presets
CMake Error: Could not read presets from /Users/clausklein/Workspace/cpp/cmake-init-shared-static:
Invalid preset: "dev"
bash-5.2$ check-jsonschema --schemafile /Users/clausklein/Downloads/cmake/Help/manual/presets/schema.json CMakeUserPresets.json
ok -- validation done
bash-5.2$ 

And the documentation does nothing say about this restriction, or?

@ben.boeckel If have just tested with CMake v3.30-rc3, but it is still failling?

${hostSystemName}
The name of the host operating system. Contains the same value as CMAKE_HOST_SYSTEM_NAME. This is allowed in preset files specifying version 3 or above.

The documentation say nothing about a restriction!

I don’t know enough about presets to answer the question. Was a feature request for this ever filed?

No, IMHO: this is either a BUG in the documentation or the implementation!

Some fields are marked with This field supports macro expansion, but for example, the condition field not, and there it works?