diff options
author | Iyyappa Murugandi <iyyappam@microsoft.com> | 2016-12-15 02:53:30 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-12-16 14:58:43 (GMT) |
commit | c93e85d87e683e4c20e5f29726889279aea9d921 (patch) | |
tree | 9a34055de359b449c3fdec52f1326ad7a0b41c08 /Source/cmGlobalVisualStudio15Generator.cxx | |
parent | 18c8278b622e4cb9b155c5dc4ceac93322bed85f (diff) | |
download | CMake-c93e85d87e683e4c20e5f29726889279aea9d921.zip CMake-c93e85d87e683e4c20e5f29726889279aea9d921.tar.gz CMake-c93e85d87e683e4c20e5f29726889279aea9d921.tar.bz2 |
VS: Use Visual Studio Installer to locate VS 2017
VS 2017 and later may no longer populate the Windows Registry entries
CMake has traditionally used to find the VS installations. This is
because VS now supports having multiple installations of the same
version. The Visual Studio Installer tool provides a COM interface we
can query to locate installations.
Diffstat (limited to 'Source/cmGlobalVisualStudio15Generator.cxx')
-rw-r--r-- | Source/cmGlobalVisualStudio15Generator.cxx | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/Source/cmGlobalVisualStudio15Generator.cxx b/Source/cmGlobalVisualStudio15Generator.cxx index 4299081..d11ee7c 100644 --- a/Source/cmGlobalVisualStudio15Generator.cxx +++ b/Source/cmGlobalVisualStudio15Generator.cxx @@ -8,6 +8,7 @@ #include "cmMakefile.h" #include "cmVS141CLFlagTable.h" #include "cmVS141CSharpFlagTable.h" +#include "cmVSSetupHelper.h" static const char vs15generatorName[] = "Visual Studio 15 2017"; @@ -126,21 +127,44 @@ bool cmGlobalVisualStudio15Generator::SelectWindowsStoreToolset( bool cmGlobalVisualStudio15Generator::IsWindowsDesktopToolsetInstalled() const { - const char desktop10Key[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\" - "VisualStudio\\15.0\\VC\\Runtimes"; - - std::vector<std::string> vc15; - return cmSystemTools::GetRegistrySubKeys(desktop10Key, vc15, - cmSystemTools::KeyWOW64_32); + return vsSetupAPIHelper.IsVS2017Installed(); } bool cmGlobalVisualStudio15Generator::IsWindowsStoreToolsetInstalled() const { - const char universal10Key[] = - "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\" - "VisualStudio\\15.0\\Setup\\Build Tools for Windows 10;SrcPath"; + return vsSetupAPIHelper.IsWin10SDKInstalled(); +} + +std::string cmGlobalVisualStudio15Generator::FindMSBuildCommand() +{ + std::string msbuild; + + // Ask Visual Studio Installer tool. + std::string vs; + if (vsSetupAPIHelper.GetVSInstanceInfo(vs)) { + msbuild = vs + "/MSBuild/15.0/Bin/MSBuild.exe"; + if (cmSystemTools::FileExists(msbuild)) { + return msbuild; + } + } + + msbuild = "MSBuild.exe"; + return msbuild; +} + +std::string cmGlobalVisualStudio15Generator::FindDevEnvCommand() +{ + std::string devenv; + + // Ask Visual Studio Installer tool. + std::string vs; + if (vsSetupAPIHelper.GetVSInstanceInfo(vs)) { + devenv = vs + "/Common7/IDE/devenv.com"; + if (cmSystemTools::FileExists(devenv)) { + return devenv; + } + } - std::string win10SDK; - return cmSystemTools::ReadRegistryValue(universal10Key, win10SDK, - cmSystemTools::KeyWOW64_32); + devenv = "devenv.com"; + return devenv; } |