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

**URL:** <https://discourse.cmake.org/t/error-4-9-invalid-include-field-in-cmake-preset/10554>\
**Category:** Code\
**Created:** [April 2, 2024, 3:58pm UTC](https://discourse.cmake.org/t/error-4-9-invalid-include-field-in-cmake-preset/10554 "2024-04-02T15:58:16Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Post date:** [April 2, 2024, 3:58pm UTC](https://discourse.cmake.org/t/error-4-9-invalid-include-field-in-cmake-preset/10554/1 "2024-04-02T15:58:16Z")

</div>

`${hostSystemName}`

The name of the host operating system. Contains the same value as [`CMAKE_HOST_SYSTEM_NAME`](https://cmake.org/cmake/help/latest/variable/CMAKE_HOST_SYSTEM_NAME.html#variable:CMAKE_HOST_SYSTEM_NAME). This is allowed in preset files specifying version `3` or above.

### I am wondering this fails:

```json
{
    "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"
                }
            ]
        }
    ]
}

```

---

<div class="post-metadata">

**Author:** ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Post date:** [April 2, 2024, 6:19pm UTC](https://discourse.cmake.org/t/error-4-9-invalid-include-field-in-cmake-preset/10554/2 "2024-04-02T18:19:12Z")

</div>

with **cmake version 3.29.20240402-gf8ba5b1** works fine. 😀

fixed with [MR#9108](https://gitlab.kitware.com/cmake/cmake/-/merge_requests/9108)

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

---

<div class="post-metadata">

**Author:** ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Post date:** [April 7, 2024, 5:59pm UTC](https://discourse.cmake.org/t/error-4-9-invalid-include-field-in-cmake-preset/10554/3 "2024-04-07T17:59:06Z")

</div>

@ben.boeckel but this is still not valid?

```json
{
  "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
      }
    }
  ]
}

```

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [April 10, 2024, 11:09pm UTC](https://discourse.cmake.org/t/error-4-9-invalid-include-field-in-cmake-preset/10554/4 "2024-04-10T23:09:33Z")

</div>

No idea? What’s the issue here?

---

<div class="post-metadata">

**Author:** ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Post date:** [April 11, 2024, 10:12am UTC](https://discourse.cmake.org/t/error-4-9-invalid-include-field-in-cmake-preset/10554/5 "2024-04-11T10:12:15Z")

</div>

> [@ClausKlein](#):
>
> `"inherits": ["dev-mode", "vcpkg", "ci-${hostSystemName}"],`  
> `"inherits": ["dev-mode", "vcpkg", "ci-$env{hostSystemName}"],`

### both results in invalid preset!

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [April 11, 2024, 3:33pm UTC](https://discourse.cmake.org/t/error-4-9-invalid-include-field-in-cmake-preset/10554/6 "2024-04-11T15:33:39Z")

</div>

@kyle.edwards Thoughts?

---

<div class="post-metadata">

**Author:** ![kyle.edwards](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/65b543/32.png) [@kyle.edwards](https://discourse.cmake.org/u/kyle.edwards)\
**Post date:** [April 11, 2024, 3:35pm UTC](https://discourse.cmake.org/t/error-4-9-invalid-include-field-in-cmake-preset/10554/7 "2024-04-11T15:35:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Post date:** [April 11, 2024, 3:51pm UTC](https://discourse.cmake.org/t/error-4-9-invalid-include-field-in-cmake-preset/10554/8 "2024-04-11T15:51:56Z")

</div>

That is the problem!

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [April 11, 2024, 4:27pm UTC](https://discourse.cmake.org/t/error-4-9-invalid-include-field-in-cmake-preset/10554/9 "2024-04-11T16:27:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Post date:** [April 11, 2024, 9:04pm UTC](https://discourse.cmake.org/t/error-4-9-invalid-include-field-in-cmake-preset/10554/10 "2024-04-11T21:04:14Z")

</div>

```bash
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?

---

<div class="post-metadata">

**Author:** ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Post date:** [June 16, 2024, 3:45pm UTC](https://discourse.cmake.org/t/error-4-9-invalid-include-field-in-cmake-preset/10554/11 "2024-06-16T15:45:06Z")

</div>

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

```auto
${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!

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [June 16, 2024, 7:02pm UTC](https://discourse.cmake.org/t/error-4-9-invalid-include-field-in-cmake-preset/10554/12 "2024-06-16T19:02:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Post date:** [June 16, 2024, 7:21pm UTC](https://discourse.cmake.org/t/error-4-9-invalid-include-field-in-cmake-preset/10554/13 "2024-06-16T19:21:14Z")

</div>

> [@ClausKlein](#):
>
> ```auto
> ${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.
> 
> ```

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?
