question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for microsoft.com/VisualStudioSettings/CMake/1.0 vendor option in CMakePresets.json

See original GitHub issue

Brief Issue Summary

CMakePresets for windows targets using msvc cannot be configured easily as there is no support for the cmakeGenerateCommand vendor option. The only reason this is useful is due to the fact that we must call vcvarsall.bat to load all the required envs to build against msvc. We’ve been achomplishing this through bat files that use vswhere to first locate, then execute the vcvarsall bat file.

Note I am able to use cmake presets in visual studio 2019 preview, and it works great.

The vendor section in question is:

				"microsoft.com/VisualStudioSettings/CMake/1.0": {
					"cmakeGenerateCommand": "setup.bat Debug"
				}
			}

I will note that this is in the json schema definition in vscode, however there is no logic to execute it.

So until this is supported I am relying on the cmake-kits/cmake-variants flow as it supports the option ‘environmentSetupScript’

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:15 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
andreeiscommented, Jun 9, 2021

@esweet431, some thoughts to think about from the last comment.

1reaction
JasonDictoscommented, Jun 1, 2021

I think if we could add a vendor option that works just like the cmake-kits option ‘environmentSetupScript’, then that’d be a complete solution, as for example I could run a script like so to automatically, and generically, setup the proper build env prior to cmake config:


for /f "usebackq tokens=*" %%i in (`"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere" -prerelease -requires Microsoft.Component.MSBuild -find \**\vcvarsall.bat`) do SET VCVARSPATH=%%i
call "%VCVARSPATH%" x86_amd64

Then I could use CMakePresets, although this would ideally be handled by something within cmake I suppose as otherwise the only use case that would work would be an interactive vscode dev environment. When we really need something that can work purely with cmake for CI/Pipeline scripting.

As far as doing this all in a toolchain, yeah thats possible but simply not really easy to do and fairly confusing, but I get why that would be the recommended approach.

Bottom line is, everyone who develops on windows has this hurdle with vcvars, and as much as everyone likes to declare ‘its out of scope for our particular component’, everyone still suffers and everyone still is writing additional tooling to work around it.

Having this built into cmake would be just awesome, like native vcvars loading and detection etc.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CMakeUserPresets.json - Microsoft Learn
The Visual Studio Settings vendor map is supported by both CMakePresets.json and CMakeUserPresets.json . The options in the Visual Studio ...
Read more >
Not able to build when using CMakePresets.json
Your open channel to Microsoft engineering teams ... 13 0 1 ... This issue seemed to occur after I had adding...
Read more >
An Introduction to CMakePresets.json - YouTube
Check out free documentation and modules on Microsoft Learn: https://docs. microsoft.com/en-us/cpp/?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found