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

Setting only the VS toolset name in CMakePresets.json does not select the correct toolset for Ninja generators #2423

Closed
Djoulihen opened this issue Mar 12, 2022 · 4 comments · Fixed by #2524
Labels
bug a bug in the product Feature: presets
Projects
Milestone

Comments

@Djoulihen
Copy link

When specifying a toolset name in CMakePresets.json, the correct toolset version is selected when using Visual Studio generators but not Ninja Generators.

I have both VS 2017 and VS 2019 installed on my computer. I'm using the following preset:

{
    "name": "Ninja",
    "generator": "Ninja Multi-Config",
    "architecture": {
        "strategy": "external",
        "value": "x64"
    },
    "toolset": {
        "strategy": "external",
        "value": "v141,host=x64"
    },
    "cacheVariables": {
        "CMAKE_CXX_COMPILER": "cl"
    }
},

When running the cmake configuration, I get:

[preset] Configure preset Ninja: No toolset version specified for cl.exe, using latest by default
[preset] Using developer environment from Visual Studio (instance 59fddfac, version 16.11.31729.503, installed at "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional")

And the toolset with version 14.29.30133 is used. This corresponds to v142, not v141. Using the same configuration with a Visual Studio Generator selects the correct toolset version (14.16.XXX for v141).

Pull request #2366 allows us to specify the toolset version directly as part of the toolset string, which can be used to select the correct version. If I use "toolset": { "value": "v141,version=14.16.27023,host=x64", "strategy": "external" } then the 14.16.27023 toolset is correctly selected. However, only specifying the toolset name should also be supported.

See #1965 for more context about this issue.

@Djoulihen Djoulihen changed the title Setting only the VS toolset name in CMakePresets.json does not work for Ninja generators Setting only the VS toolset name in CMakePresets.json does not select the correct toolset for Ninja generators Mar 12, 2022
@bobbrow
Copy link
Member

bobbrow commented Mar 22, 2022

Thanks for opening an issue to track this. The current workaround is to specify the version in the string as well (a two-part version number is sufficient).

@bobbrow bobbrow added bug a bug in the product Feature: presets labels Mar 22, 2022
@bobbrow bobbrow added this to the On Deck milestone Mar 22, 2022
@bobbrow bobbrow added this to Triage in 1.11 via automation Mar 22, 2022
@jakoch
Copy link

jakoch commented Apr 20, 2022

Just using a two-part version, like 14.32, didn't work for me. Only passing the full version number worked.
So i ended up with:

"toolset": {
    "value": "v143,host=x64,version=14.32.31326",
    "strategy": "external"
},

For those running into the same issue:
You can find the version number by opening the Developer Command Prompt for the desired MSVC version
and running echo %VCToolsVersion%.

@bobbrow
Copy link
Member

bobbrow commented Apr 22, 2022

@jakoch we'll need to look into that. It should be working with the two-part version 😕

@bobbrow bobbrow moved this from Triage to To do in 1.11 Apr 22, 2022
@bobbrow bobbrow linked a pull request Apr 25, 2022 that will close this issue
@bobbrow bobbrow moved this from To do to In progress in 1.11 Apr 25, 2022
1.11 automation moved this from In progress to Done Apr 26, 2022
@bobbrow bobbrow modified the milestones: On Deck, 1.11.0 Apr 26, 2022
@bobbrow
Copy link
Member

bobbrow commented Apr 26, 2022

The fix for this will be available in tomorrow's pre-release version.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug a bug in the product Feature: presets
Projects
No open projects
1.11
Done
Development

Successfully merging a pull request may close this issue.

3 participants