Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors setting the Windows SDK version in a Configure Preset #3672

Closed
benschreiber opened this issue Mar 27, 2024 · 1 comment
Closed

Errors setting the Windows SDK version in a Configure Preset #3672

benschreiber opened this issue Mar 27, 2024 · 1 comment
Assignees
Labels
bug a bug in the product
Milestone

Comments

@benschreiber
Copy link

Brief Issue Summary

Beginning with CMake 3.27, you can specify a Windows SDK version in CMAKE_GENERATOR_PLATFORM. This variable can also be set with cmake -A or the architecture field in a configure preset. Consider the following presets.

{
    "version": 6,
    "configurePresets": [
        {
            "name": "msvc",
            "generator": "Visual Studio 16 2019",
            "toolset": "host=x64",
            "architecture": "x64,version=10.0.19041.0",
            "cacheVariables": {
                "CMAKE_CXX_COMPILER": "cl.exe"
            }
        },
        {
            "name": "ninja",
            "generator": "Ninja Multi-Config",
            "toolset": {
                "value": "host=x64",
                "strategy": "external"
            },
            "architecture": {
                "value": "x64,version=10.0.19041.0",
                "strategy": "external"
            },
            "cacheVariables": {
                "CMAKE_CXX_COMPILER": "cl.exe"
            }
        }
    ]
}

From the CLI, the msvc preset works correctly.

cmake --preset msvc
...
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19045.

In VS Code, the msvc preset shows errors in the log when loading.

[ERROR:vcvarsall.bat] Invalid argument found : x64_x64=version
[ERROR:vcvarsall.bat] Error in script usage. The correct usage is:

but it does seem to work correctly?

[cmake] -- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19045.

Without specifying version=10.0.19041.0, I see

[cmake] -- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19045.

The ninja preset fails to find cl.exe when specifying version=10.0.19041.0, but it works without it.

[cmake] CMake Error at CMakeLists.txt:3 (project):
[cmake]   The CMAKE_CXX_COMPILER:
[cmake] 
[cmake]     cl.exe
[cmake] 
[cmake]   is not a full path and was not found in the PATH.

CMake Tools Diagnostics

{
  "os": "win32",
  "vscodeVersion": "1.87.2",
  "cmtVersion": "1.17.17",
  "configurations": [
    {
      "folder": "c:\\Users\\bschreiber\\Developer\\cmake_repro",
      "cmakeVersion": "3.28.0",
      "configured": true,
      "generator": "Ninja Multi-Config",
      "usesPresets": true,
      "compilers": {
        "C": "C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x64/cl.exe",
        "CXX": "C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x64/cl.exe"
      }
    }
  ],
  "cpptoolsIntegration": {
    "isReady": false,
    "hasCodeModel": false,
    "activeBuildType": "",
    "buildTypesSeen": [],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 0,
    "executablesCount": 0,
    "librariesCount": 0,
    "targets": []
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": false
    }
  ]
}

Debug Log

No response

Additional Information

No response

@gcampbell-msft
Copy link
Collaborator

@benschreiber Ah, this looks like the "magic" that we do in order to pull in the development environment from Visual Studio is failing when it tries to parse the arguments and call the vcvarsall.bat script. We'll add this to the backlog.

Thanks!

@gcampbell-msft gcampbell-msft added bug a bug in the product and removed triage labels Mar 29, 2024
@gcampbell-msft gcampbell-msft added this to the 1.18 milestone Mar 29, 2024
@gcampbell-msft gcampbell-msft moved this from Triage Needed to In Progress in CMake Tools Mar 29, 2024
@gcampbell-msft gcampbell-msft self-assigned this Mar 29, 2024
@gcampbell-msft gcampbell-msft moved this from In Progress to Completed in CMake Tools Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug a bug in the product
Projects
Status: Completed
Development

No branches or pull requests

2 participants