diff options
author | Brad King <brad.king@kitware.com> | 2016-10-11 17:36:41 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-10-11 17:39:58 (GMT) |
commit | 5380948faec94270f9b799fba6f8b0e7c9ad0899 (patch) | |
tree | 9e82dcc9cffc0e9cfba18bf7e256a8236847a241 /Source/cmake.cxx | |
parent | 1aee54ed87f94ceb91fb6c9693160fa41313b7ca (diff) | |
download | CMake-5380948faec94270f9b799fba6f8b0e7c9ad0899.zip CMake-5380948faec94270f9b799fba6f8b0e7c9ad0899.tar.gz CMake-5380948faec94270f9b799fba6f8b0e7c9ad0899.tar.bz2 |
cmake: Fix default VS generator selection for Microsoft Build Tools
Some versions of the VS tools do not install the registry entry
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\$v;InstallDir
but all appear to set
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\$v\Setup\VC;ProductDir
Update our search to consider both entries.
Closes: #16360
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r-- | Source/cmake.cxx | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 78f8c48..b4ab42e 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1467,17 +1467,23 @@ void cmake::CreateDefaultGlobalGenerator() { "8.0", "Visual Studio 8 2005" }, // { "7.1", "Visual Studio 7 .NET 2003" } }; + static const char* const vsEntries[] = { + "\\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) { - std::string reg = vsregBase + *v + g->MSVersion; - reg += ";InstallDir"; - std::string dir; - if (cmSystemTools::ReadRegistryValue(reg, dir, - cmSystemTools::KeyWOW64_32) && - cmSystemTools::PathExists(dir)) { - found = g->GeneratorName; + 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; + } } } } |