From 93c718791e4e81f37dcc3413b3e847d94313d5c9 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 24 Jun 2021 16:25:42 -0400 Subject: VS: Use 64-bit MSBuild in VS 2022 Visual Studio 17 2022 is now a 64-bit native application. It places the 64-bit `MSBuild.exe` in the `PATH` of VS command prompts, so prefer it for this version and above. This was previously attempted for older VS versions, but reverted by commit f3cedf381e (VS: Revert "Use MSBuild matching toolset host architecture", 2019-03-12, v3.14.0~1^2). For now, do not use the 64-bit MSBuild for VS 16 and below. Fixes: #18219 --- Source/cmGlobalVisualStudioVersionedGenerator.cxx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx index a2b5258..aafc9d5 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx +++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx @@ -716,6 +716,12 @@ std::string cmGlobalVisualStudioVersionedGenerator::FindMSBuildCommand() // Ask Visual Studio Installer tool. std::string vs; if (vsSetupAPIHelper.GetVSInstanceInfo(vs)) { + if (this->Version >= cmGlobalVisualStudioGenerator::VS17) { + msbuild = vs + "/MSBuild/Current/Bin/amd64/MSBuild.exe"; + if (cmSystemTools::FileExists(msbuild)) { + return msbuild; + } + } msbuild = vs + "/MSBuild/Current/Bin/MSBuild.exe"; if (cmSystemTools::FileExists(msbuild)) { return msbuild; -- cgit v0.12