summaryrefslogtreecommitdiffstats
path: root/Source/cmake.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-10-11 15:35:49 (GMT)
committerBrad King <brad.king@kitware.com>2016-10-11 15:46:45 (GMT)
commit0838d20e506ed6bf064b51f7ef2d026c76b4af3d (patch)
tree769e257a3cf6d96b299630d9b02f1ba1bc933fe5 /Source/cmake.cxx
parent8f33de92ba4fc152b0e2b63008732ce0ad4ba18c (diff)
downloadCMake-0838d20e506ed6bf064b51f7ef2d026c76b4af3d.zip
CMake-0838d20e506ed6bf064b51f7ef2d026c76b4af3d.tar.gz
CMake-0838d20e506ed6bf064b51f7ef2d026c76b4af3d.tar.bz2
cmake: Simplify VS registry entry lookup
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r--Source/cmake.cxx10
1 files changed, 6 insertions, 4 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 3bf7f38..be08fc7 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -1447,7 +1447,7 @@ void cmake::CreateDefaultGlobalGenerator()
std::string installedCompiler;
// Try to find the newest VS installed on the computer and
// 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;
vsVerions.push_back("VisualStudio\\");
vsVerions.push_back("VCExpress\\");
@@ -1472,9 +1472,11 @@ void cmake::CreateDefaultGlobalGenerator()
for (int i = 0; version[i].MSVersion != 0; i++) {
for (size_t b = 0; b < vsVerions.size(); b++) {
std::string reg = vsregBase + vsVerions[b] + version[i].MSVersion;
- reg += ";InstallDir]";
- cmSystemTools::ExpandRegistryValues(reg, cmSystemTools::KeyWOW64_32);
- if (!(reg == "/registry")) {
+ reg += ";InstallDir";
+ std::string dir;
+ if (cmSystemTools::ReadRegistryValue(reg, dir,
+ cmSystemTools::KeyWOW64_32) &&
+ cmSystemTools::PathExists(dir)) {
installedCompiler = version[i].GeneratorName;
break;
}