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

Support "external" strategy of "toolset" and "architecture" fields in CMakePresets.json for MSVC compilers.

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Fixed
    • Not Evaluated
    • Qt Creator 10.0.0
    • Qt Creator 9.0.1
    • None
    • Windows 11
      MSVC16 (VS2019), MSVC17 (VS2022)
      Qt Creator 9.0.1
      CMake 3.25.1
      Ninja 1.11.1

    • Windows
    • e8802d92e (10.0)

    Description

      Suggestion

      According to this article of Qt Blog, it is required to specify lots of environment variables in CMakePresets.json when using MSVC compilers with NMake Makefiles, Ninja, or Ninja Multi-Config generators.

      However, we won't need to do so when using VSCode with CMake Tools extension. We can simply use the "external" strategy of "toolset" and "architecture" fields in CMakePresets.json, and then CMake Tools will autodetect which MSVC compiler should be used.

      For example:

      • If we want to use "MSVC16(VS2019) x64" compiler, then:
        "generator": "Ninja Multi-Config",
        "toolset": {
          "value": "v142,host=x64",
          "strategy": "external"
        },
        "architecture": {
          "value": "x64",
          "strategy": "external"
        },
        
      • If we want to use "MSVC16(VS2019) x86" compiler, then
        "generator": "Ninja Multi-Config",
        "toolset": {
          "value": "v142,host=x86",
          "strategy": "external"
        },
        "architecture": {
          "value": "x86",
          "strategy": "external"
        },
        
      • If we want to use "MSVC17(VS2022) x64_x86" compiler, then
        "generator": "Ninja Multi-Config",
        "toolset": {
          "value": "v143,host=x64",
          "strategy": "external"
        },
        "architecture": {
          "value": "x86",
          "strategy": "external"
        },
        
      • If we want to use "MSVC17(VS2022) x86_x64" compiler, then
        "generator": "Ninja Multi-Config",
        "toolset": {
          "value": "v143,host=x86",
          "strategy": "external"
        },
        "architecture": {
          "value": "x64",
          "strategy": "external"
        },
        

      I hope QtCreator can support this mechanism as well. Otherwise, it is inconvenient to specify so many hardcoded environment variables.

      Attachments

        1. screenshots-of-qt-blog.png
          79 kB
          Haowei Hsu
        2. screenshots-of-qt-blog-2.png
          72 kB
          Haowei Hsu

        Activity

          People

            cadam Cristian Adam
            hwhsu1231 Haowei Hsu
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: