Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-28893

CMakePresets.json : macros are not evaluated in the context of the preset used

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Not Evaluated
    • Qt Creator 10.0.0
    • Qt Creator 10.0.0-beta2, Qt Creator 10.0.0-rc1
    • None
    • Rocky Linux 8
      QtCreator 10 beta 2
      CMake 3.25.2
    • 40a22963b (10.0)

    Description

      If you add base preset like (CMakePresetsBase.json)

      {
        "version": 4,
        "configurePresets": [
          {
            "name": "Linux-CPP-only-toolset-configure",
            "hidden": true,
            "generator": "Unix Makefiles",
            "binaryDir": "${sourceDir}/build/${generator}/${presetName}",
            "environment":

      {         "PATH": "/opt/rh/gcc-toolset-11/root/usr/bin:$penv

      {PATH}

      ",
              "CXX": "g++",
              "CC": "gcc"
            }
          }
        ]

      }

      And try to use as common include at different file:
      {
        "version": 4,
        "include": [
          "../../../../CMakePresetsBase.json"
        ],
        "configurePresets": [
          {
            "inherits": "Linux-CPP-only-toolset-configure",
            "name": "Release",
            "displayName": "CPP-only-toolset-Release",
            "cacheVariables":

      {         "CMAKE_BUILD_TYPE": "Release"       }

      ,
            "condition": {
              "type": "equals",
              "lhs": "${hostSystemName}",
              "rhs": "Linux"
            }
          },
          {
            "inherits": "Linux-CPP-only-toolset-configure",
            "name": "Debug",
            "displayName": "CPP-only-toolset-Debug",
            "cacheVariables":

      {         "CMAKE_BUILD_TYPE": "Debug"       }

      ,
            "condition": {
              "type": "equals",
              "lhs": "${hostSystemName}",
              "rhs": "Linux"
            }
          }
        ]

      }

      At QtCreator You'll find unevaluated string as a binary directory.

      Case of debug shows inheritance from another file (include)

      Case of Release shows inheritance from the same file.

      But command line calls of cmake work as expected.
      cmake --preset=Release

      cmake --build --preset=Release

       

      Cmake documentation link
      https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html#macro-expansion

       

      Attachments

        Issue Links

          Activity

            People

              cadam Cristian Adam
              paval Paval Liavonau
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: