# Workflow Presets: We need support for macro expansion in inherits field

**URL:** https://discourse.cmake.org/t/workflow-presets-we-need-support-for-macro-expansion-in-inherits-field/8798
**Category:** Development
**Created:** [August 22, 2023, 6:49am UTC](https://discourse.cmake.org/t/workflow-presets-we-need-support-for-macro-expansion-in-inherits-field/8798 "2023-08-22T06:49:52Z")
**Posts on this page:** 11
**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: [August 22, 2023, 6:49am UTC](https://discourse.cmake.org/t/workflow-presets-we-need-support-for-macro-expansion-in-inherits-field/8798/1 "2023-08-22T06:49:52Z")

</div>

As **duplicate preset names** with `unique conditon` are **not supported** ,  
do we needs at least macro expansion in `inherits` fields:

```json
    {
      "name": "dev",
      "displayName": "Ninja developer build with coverage",
      "inherits": ["dev-coverage", "dev-${hostSystemName}"]
    }

```

The full example `CMakeUserPrests.json`:

```json
{
  "version": 6,
  "configurePresets": [
    {
      "name": "dev-common",
      "hidden": true,
      "inherits": ["dev-mode", "conan"],
      "generator": "Ninja",
      "installDir": "${sourceDir}/stagedir",
      "cacheVariables": {
        "BUILD_MCSS_DOCS": "OFF",
        "CMAKE_PREFIX_PATH": {
          "type": "path",
          "value": "${sourceDir}/stagedir"
        }
      }
    },
    {
      "name": "dev-coverage",
      "hidden": true,
      "binaryDir": "${sourceDir}/build/coverage",
      "inherits": ["coverage-unix", "dev-common"]
    },
    {
      "name": "dev-Linux",
      "binaryDir": "${sourceDir}/build/dev-linux",
      "inherits": ["dev-common", "ci-linux"],
      "cacheVariables": {
        "CMAKE_BUILD_TYPE": "Debug",
        "CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
      },
      "condition": {
          "type": "equals",
          "lhs": "${hostSystemName}",
          "rhs": "Linux"
      }
    },
    {
      "name": "dev-Darwin",
      "binaryDir": "${sourceDir}/build/dev-darwin",
      "inherits": ["dev-common", "ci-darwin"],
      "cacheVariables": {
        "CMAKE_BUILD_TYPE": "Debug",
        "CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
      },
      "condition": {
          "type": "equals",
          "lhs": "${hostSystemName}",
          "rhs": "Darwin"
      }
    },
    {
      "name": "dev-Windows",
      "binaryDir": "${sourceDir}/build/dev-win64",
      "inherits": ["dev-common", "ci-win64"],
      "environment": {
        "UseMultiToolTask": "true",
        "EnforceProcessCountAcrossBuilds": "true"
      },
      "condition": {
          "type": "equals",
          "lhs": "${hostSystemName}",
          "rhs": "Windows"
      }
    },
    {
      "name": "dev",
      "displayName": "Ninja developer build with coverage",
      "inherits": ["dev-coverage", "dev-${hostSystemName}"]
    }
  ],
  "buildPresets": [
    {
      "name": "dev",
      "configurePreset": "dev",
      "configuration": "Debug"
    },
    {
      "name": "all",
      "configurePreset": "dev",
      "configuration": "Debug",
      "targets": ["all", "format-fix"]
    },
    {
      "name": "check",
      "configurePreset": "dev",
      "configuration": "Debug",
      "targets": ["test", "run-exe", "install", "spell-check"]
    }
  ],
  "testPresets": [
    {
      "name": "dev",
      "configurePreset": "dev",
      "configuration": "Debug",
      "output": {
        "outputOnFailure": true
      },
      "execution": {
        "noTestsAction": "error"
      }
    }
  ],
  "workflowPresets": [
    {
      "name": "dev",
      "steps": [
        {
          "type": "configure",
          "name": "dev"
        },
        {
          "type": "build",
          "name": "all"
        },
        {
          "type": "build",
          "name": "check"
        },
        {
          "type": "test",
          "name": "dev"
        }
      ]
    }
  ]
}

```

---

<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: [August 22, 2023, 10:51am UTC](https://discourse.cmake.org/t/workflow-presets-we-need-support-for-macro-expansion-in-inherits-field/8798/2 "2023-08-22T10:51:29Z")

</div>

Cc: @kyle.edwards

---

<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: [August 22, 2023, 10:55am UTC](https://discourse.cmake.org/t/workflow-presets-we-need-support-for-macro-expansion-in-inherits-field/8798/3 "2023-08-22T10:55:20Z")

</div>

I have a lot of preset item open without a real reaction from @kyle.edwards ?

---

<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: [August 22, 2023, 2:11pm UTC](https://discourse.cmake.org/t/workflow-presets-we-need-support-for-macro-expansion-in-inherits-field/8798/4 "2023-08-22T14:11:07Z")

</div>

He authored much of the feature; I don’t use them and don’t have a lot of knowledge about it. I don’t know his schedule for Discourse things, but the mention should get it more onto his radar.

---

<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 18, 2024, 5:41pm UTC](https://discourse.cmake.org/t/workflow-presets-we-need-support-for-macro-expansion-in-inherits-field/8798/5 "2024-06-18T17:41:21Z")

</div>

Starting with `CMake v3.30` this workaround exists.

I have this preset files:  
**CMakeDarwinPresets.json**

**CMakeGenericPresets.json**

**CMakeLinuxPresets.json**

**CMakePresets.json**

**CMakeWindowsPresets.json**

```json
{
  "version": 9,
  "cmakeMinimumRequired": {
    "major": 3,
    "minor": 30,
    "patch": 0
  },
  "include": [
    "CMake${hostSystemName}Presets.json"
  ],
  "configurePresets": [
    {
      "name": "dev",
      "displayName": "developer Ninja build on unix with Coverage",
      "description": "NOTE: coverage must be the first to overwrite Release build! CK",
      "inherits": [
        "ci-coverage",
        "doxygen"
      ],
      "generator": "Ninja"
    }
  ],
  "buildPresets": [
    {
      "name": "dev",
      "configurePreset": "dev",
      "configuration": "Coverage",
      "targets": [
        "all"
      ]
    }
  ],
  "testPresets": [
    {
      "name": "dev",
      "configurePreset": "dev",
      "configuration": "Coverage",
      "output": {
        "outputOnFailure": true
      }
    }
  ],
  "workflowPresets": [
    {
      "name": "dev",
      "steps": [
        {
          "type": "configure",
          "name": "dev"
        },
        {
          "type": "build",
          "name": "dev"
        },
        {
          "type": "test",
          "name": "dev"
        }
      ]
    }
  ]
}

```

---

<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 18, 2024, 5:42pm UTC](https://discourse.cmake.org/t/workflow-presets-we-need-support-for-macro-expansion-in-inherits-field/8798/6 "2024-06-18T17:42:27Z")

</div>

with a `CMakeDarwinPresets.json`

```json
{
  "version": 4,
  "cmakeMinimumRequired": {
    "major": 3,
    "minor": 23,
    "patch": 0
  },
  "include": [
    "CMakeGenericPresets.json"
  ],
  "configurePresets": [
    {
      "name": "flags-appleclang",
      "hidden": true,
      "cacheVariables": {
        "CMAKE_CXX_FLAGS": "-fstack-protector-strong -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wcast-qual -Wformat=2 -Wundef -Werror=float-equal -Wshadow -Wcast-align -Wunused -Wnull-dereference -Wdouble-promotion -Wimplicit-fallthrough -Wextra-semi -Woverloaded-virtual -Wnon-virtual-dtor -Wold-style-cast"
      }
    },
    {
      "name": "ci-darwin",
      "generator": "Unix Makefiles",
      "hidden": true,
      "inherits": [
        "flags-appleclang",
        "ci-std"
      ],
      "cacheVariables": {
        "CMAKE_BUILD_TYPE": "Release"
      }
    },
    {
      "name": "coverage-darwin",
      "binaryDir": "${sourceDir}/build/coverage",
      "inherits": "ci-darwin",
      "hidden": true,
      "cacheVariables": {
        "ENABLE_COVERAGE": true,
        "CMAKE_BUILD_TYPE": "Coverage",
        "CMAKE_CXX_FLAGS_COVERAGE": "-Og -g --coverage",
        "CMAKE_EXE_LINKER_FLAGS_COVERAGE": "--coverage",
        "CMAKE_SHARED_LINKER_FLAGS_COVERAGE": "--coverage"
      }
    },
    {
      "name": "ci-coverage",
      "inherits": [
        "coverage-darwin",
        "dev-mode"
      ],
      "cacheVariables": {
        "COVERAGE_HTML_COMMAND": ""
      }
    },
    {
      "name": "ci-sanitize",
      "binaryDir": "${sourceDir}/build/sanitize",
      "inherits": [
        "ci-darwin",
        "dev-mode"
      ],
      "cacheVariables": {
        "CMAKE_BUILD_TYPE": "Sanitize",
        "CMAKE_CXX_FLAGS_SANITIZE": "-U_FORTIFY_SOURCE -O2 -g -fsanitize=address,undefined -fno-omit-frame-pointer -fno-common"
      }
    },
    {
      "name": "ci-Darwin",
      "inherits": [
        "ci-build",
        "ci-darwin",
        "clang-tidy",
        "dev-mode"
      ]
    },
    {
      "name": "ci-macos",
      "inherits": "ci-Darwin"
    }
  ]
}

```

---

<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 18, 2024, 5:44pm UTC](https://discourse.cmake.org/t/workflow-presets-we-need-support-for-macro-expansion-in-inherits-field/8798/7 "2024-06-18T17:44:37Z")

</div>

and a `CMakeGenericPresets.json`

```auto
{
  "version": 3,
  "cmakeMinimumRequired": {
    "major": 3,
    "minor": 21,
    "patch": 0
  },
  "configurePresets": [
    {
      "name": "cmake-pedantic",
      "hidden": true,
      "warnings": {
        "dev": true,
        "deprecated": true,
        "uninitialized": true,
        "unusedCli": true,
        "systemVars": false
      },
      "errors": {
        "dev": true,
        "deprecated": true
      }
    },
    {
      "name": "dev-mode",
      "hidden": true,
      "inherits": "cmake-pedantic",
      "installDir": "${sourceDir}/stagedir",
      "cacheVariables": {
        "CMAKE_PREFIX_PATH": {
          "type": "path",
          "value": "${sourceDir}/stagedir"
        },
        "shared_DEVELOPER_MODE": true,
        "CMAKE_EXPORT_COMPILE_COMMANDS": true,
        "BUILD_SHARED_LIBS": true,
        "BUILD_TESTING": true
      }
    },
    {
      "name": "doxygen",
      "hidden": true,
      "cacheVariables": {
        "BUILD_MCSS_DOCS": true
      }
    },
    {
      "name": "cppcheck",
      "hidden": true,
      "cacheVariables": {
        "CMAKE_CXX_CPPCHECK": "cppcheck;--inline-suppr"
      }
    },
    {
      "name": "clang-tidy",
      "hidden": true,
      "cacheVariables": {
        "CMAKE_CXX_CLANG_TIDY": "clang-tidy;--header-filter=^${sourceDir}/"
      }
    },
    {
      "name": "ci-std",
      "description": "This preset makes sure the project actually builds with at least the specified standard",
      "hidden": true,
      "cacheVariables": {
        "CMAKE_CXX_EXTENSIONS": false,
        "CMAKE_CXX_STANDARD": "20",
        "CMAKE_CXX_STANDARD_REQUIRED": true
      }
    },
    {
      "name": "ci-build",
      "binaryDir": "${sourceDir}/build",
      "hidden": true
    }
  ]
}

```

---

<div class="post-metadata">

### Author: ![KSergeyP](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/8baadc/32.png) [@KSergeyP](https://discourse.cmake.org/u/KSergeyP)
#### Post date: [August 9, 2024, 2:18pm UTC](https://discourse.cmake.org/t/workflow-presets-we-need-support-for-macro-expansion-in-inherits-field/8798/8 "2024-08-09T14:18:58Z")

</div>

> [@ClausKlein](#):
>
> Starting with `CMake v3.30` this workaround exists.

Thank you!!!  
I’m waiting for the Ubuntu repository to update

---

<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: [August 9, 2024, 2:50pm UTC](https://discourse.cmake.org/t/workflow-presets-we-need-support-for-macro-expansion-in-inherits-field/8798/9 "2024-08-09T14:50:32Z")

</div>

> [@KSergeyP](#):
>
> ’m waiting for the Ubuntu repository to update

Don’t wait! Do  
`pip install -U ninja cmake`

---

<div class="post-metadata">

### Author: ![KSergeyP](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/8baadc/32.png) [@KSergeyP](https://discourse.cmake.org/u/KSergeyP)
#### Post date: [October 24, 2024, 8:04am UTC](https://discourse.cmake.org/t/workflow-presets-we-need-support-for-macro-expansion-in-inherits-field/8798/10 "2024-10-24T08:04:19Z")

</div>

Is it possible to use $env{VAR} for “name” and “displayName”. For example, I need several configurations to build different versions of SFML, which differ only in the version prefix in the source file paths and in “CMAKE\_INSTALL\_PREFIX”.  
I tried to set “environment”: {“VER”:“2.6.0”}, but “displayName” is displayed as “SFML $env{VAR} MinGw x64: Release”.

---

<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: [October 24, 2024, 2:16pm UTC](https://discourse.cmake.org/t/workflow-presets-we-need-support-for-macro-expansion-in-inherits-field/8798/11 "2024-10-24T14:16:59Z")

</div>

See [CMake presets issue - #6 by craig.scott](https://discourse.cmake.org/t/cmake-presets-issue/12700/6)
