Skip to content

Fix search of VCTargetsPath for VS2019 build. #698

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

Merged
merged 1 commit into from
Mar 11, 2021
Merged

Conversation

juj
Copy link
Collaborator

@juj juj commented Feb 7, 2021

This is a somewhat cryptic change about VS2017 -> VS2019, I am struggling to find information about this on the web.

It looks like a change in Windows SDK or VS2017 -> VS2019 has shuffled paths around the toolchains, hence what used to be VCTargetsPath\Common7\IDE\VC\VCTargets can now be located in VCTargetsPath\MSBuild\Microsoft\VC\v160\.

Also not quite sure I understand the role of the VCTargetsPath environment variable. The intended role of VCTargetsPath is something I don't understand properly, and it is not really well documented.

My impression of this situation is that the VCTargetsPath environment variable would have been something that Microsoft Visual Studio has once had as a property that's needed, and CMake was built to rely on it. But as newer Visual Studios came around, VCTargetsPath has been demoted to an internal VS project/solution property, and not a full environment variable. CMake however never changed, and it still expects to see VCTargetsPath when targeting Visual Studio.

The above is a complete guess however, I am struggling to find information about this on the web.

Current official VS 2019 Command Prompt does not have that environment variable. Neither does VS 2017 Command Prompt. It is something that CMake expects to see when compiling using the Visual Studio generator.

In https://discourse.cmake.org/t/cmake-failed-to-get-the-value-of-vctargetspath-with-vs2019-16-7/1839/16 Brad King, a core CMake developer suggested that If the imported file is missing, that means Visual Studio’s own VCTargetsPath is incorrect. This likely indicates a problem with its installation.. However the core issue is that Visual Studio does no longer has that env. var in 2017 or 2019, so not sure what to make of it.

In any case, this change fixes VS2019 build for me. In the future it is possible that we need to manually update the directory search list to Microsoft.Cpp.Default.props as new toolchain versions come out; unless someone knows how this stuff is supposed to work in CMake and/or VS and can offer an automated search feature :)

@juj
Copy link
Collaborator Author

juj commented Mar 11, 2021

Looks like no objections, landing..

@juj juj merged commit 772d397 into master Mar 11, 2021
@juj juj deleted the fix_vs2019_build branch March 11, 2021 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant