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

CMake configurePresets.environment.PATH is prepended instead of set

    XMLWordPrintable

Details

    • Windows
    • 5d8a8982a (14.0)

    Description

      CMakePresets.json:

      {
          "version": 5,
          "configurePresets": [
              {
                  "name": "MSVC-VS-2022-x64",
                  "displayName": "MSVC-VS-2022-x64",
                  "description": "Ninja Multi-Config Build",
                  "generator": "Ninja Multi-Config",
                  "environment": {
                      "TT_EXTERNAL_PACKAGE_BASE_PATH": "C:/TechnoTeam/develop",
                      "PATH": "$penv{SystemRoot};$penv{SystemRoot}/system32;$penv{SystemRoot}/System32/WindowsPowerShell/v1.0;$env{TT_EXTERNAL_PACKAGE_BASE_PATH}/usr/opt/tools/bin;$env{TT_EXTERNAL_PACKAGE_BASE_PATH}/usr/bin"
                  },
                  "cmakeExecutable": "$env{TT_EXTERNAL_PACKAGE_BASE_PATH}/usr/opt/tools/bin/cmake.exe"
              }
          ]
      }
       

      is interpreted by QtCreator as: (QtCreator->Projects->Build->CMake->Details)

      Use System Environment and
      Prepend ${SystemRoot};${SystemRoot}/system32;${SystemRoot}/System32/WindowsPowerShell/v1.0;C:/TechnoTeam/develop/usr/opt/tools/bin;C:/TechnoTeam/develop/usr/bin to Path
      Set TT_EXTERNAL_PACKAGE_BASE_PATH to C:/TechnoTeam/develop 

      Expected is:

      Use System Environment and
      Set Path to ${SystemRoot};${SystemRoot}/system32;${SystemRoot}/System32/WindowsPowerShell/v1.0;C:/TechnoTeam/develop/usr/opt/tools/bin;C:/TechnoTeam/develop/usr/bin
      Set TT_EXTERNAL_PACKAGE_BASE_PATH to C:/TechnoTeam/develop

      Path shouldn't get a special treatment here!

      Visual Studio and Visual Studio Code both interpret this as a Set and not a Prepent. Also the CMake Presets Doc dosn't say anything about a special treatment for Path:

      environment

      An optional map of environment variables. The key is the variable name (which may not be an empty string), and the value is either null or a string representing the value of the variable. Each variable is set regardless of whether or not a value was given to it by the process's environment. This field supports macro expansion, and environment variables in this map may reference each other, and may be listed in any order, as long as such references do not cause a cycle (for example, if ENV_1 is $env{ENV_2}{}, ENV_2 may not be $env{ENV_1}{}.)

      Environment variables are inherited through the inherits field, and the preset's environment will be the union of its own environment and the environment from all its parents. If multiple presets in this union define the same variable, the standard rules of inherits are applied. Setting a variable to null causes it to not be set, even if a value was inherited from another preset.

      This misbehavior kills our build because the environment is not in the expected state. Our workaround is to set it manually, but of course we want to avoid special configuration of IDEs.

      If you want to append or prepend, you can use $env and $penv.

      I have asked CMake for a clarification within the CMake Presets documentation.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            cadam Cristian Adam
            bebuch Benjamin Buch
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes