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/cmake.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/cmake.cxx')
-rw-r--r-- | Source/cmake.cxx | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 733e0e4..6141f50 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -64,6 +64,7 @@ #include "cmGlobalVisualStudio71Generator.h" #include "cmGlobalVisualStudio8Generator.h" #include "cmGlobalVisualStudio9Generator.h" +#include "cmVSSetupHelper.h" #define CMAKE_HAVE_VS_GENERATORS #endif @@ -1470,18 +1471,23 @@ void cmake::CreateDefaultGlobalGenerator() "\\Setup\\VC;ProductDir", // ";InstallDir" // }; - for (VSVersionedGenerator const* g = cmArrayBegin(vsGenerators); - found.empty() && g != cmArrayEnd(vsGenerators); ++g) { - for (const char* const* v = cmArrayBegin(vsVariants); - found.empty() && v != cmArrayEnd(vsVariants); ++v) { - for (const char* const* e = cmArrayBegin(vsEntries); - found.empty() && e != cmArrayEnd(vsEntries); ++e) { - std::string const reg = vsregBase + *v + g->MSVersion + *e; - std::string dir; - if (cmSystemTools::ReadRegistryValue(reg, dir, - cmSystemTools::KeyWOW64_32) && - cmSystemTools::PathExists(dir)) { - found = g->GeneratorName; + cmVSSetupAPIHelper vsSetupAPIHelper; + if (vsSetupAPIHelper.IsVS2017Installed()) { + found = "Visual Studio 15 2017"; + } else { + for (VSVersionedGenerator const* g = cmArrayBegin(vsGenerators); + found.empty() && g != cmArrayEnd(vsGenerators); ++g) { + for (const char* const* v = cmArrayBegin(vsVariants); + found.empty() && v != cmArrayEnd(vsVariants); ++v) { + for (const char* const* e = cmArrayBegin(vsEntries); + found.empty() && e != cmArrayEnd(vsEntries); ++e) { + std::string const reg = vsregBase + *v + g->MSVersion + *e; + std::string dir; + if (cmSystemTools::ReadRegistryValue(reg, dir, + cmSystemTools::KeyWOW64_32) && + cmSystemTools::PathExists(dir)) { + found = g->GeneratorName; + } } } } |