1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-06-22 20:34:08 +08:00

cmake: Simplify VS registry entry lookup

This commit is contained in:
Brad King 2016-10-11 11:35:49 -04:00
parent 8f33de92ba
commit 0838d20e50

View File

@ -1447,7 +1447,7 @@ void cmake::CreateDefaultGlobalGenerator()
std::string installedCompiler; std::string installedCompiler;
// Try to find the newest VS installed on the computer and // Try to find the newest VS installed on the computer and
// use that as a default if -G is not specified // use that as a default if -G is not specified
const std::string vsregBase = "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\"; const std::string vsregBase = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\";
std::vector<std::string> vsVerions; std::vector<std::string> vsVerions;
vsVerions.push_back("VisualStudio\\"); vsVerions.push_back("VisualStudio\\");
vsVerions.push_back("VCExpress\\"); vsVerions.push_back("VCExpress\\");
@ -1472,9 +1472,11 @@ void cmake::CreateDefaultGlobalGenerator()
for (int i = 0; version[i].MSVersion != 0; i++) { for (int i = 0; version[i].MSVersion != 0; i++) {
for (size_t b = 0; b < vsVerions.size(); b++) { for (size_t b = 0; b < vsVerions.size(); b++) {
std::string reg = vsregBase + vsVerions[b] + version[i].MSVersion; std::string reg = vsregBase + vsVerions[b] + version[i].MSVersion;
reg += ";InstallDir]"; reg += ";InstallDir";
cmSystemTools::ExpandRegistryValues(reg, cmSystemTools::KeyWOW64_32); std::string dir;
if (!(reg == "/registry")) { if (cmSystemTools::ReadRegistryValue(reg, dir,
cmSystemTools::KeyWOW64_32) &&
cmSystemTools::PathExists(dir)) {
installedCompiler = version[i].GeneratorName; installedCompiler = version[i].GeneratorName;
break; break;
} }