summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2009-09-15 02:16:43 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2009-09-15 02:16:43 (GMT)
commit77dfbd49b405298e358a1697097eb7a53c4ff217 (patch)
tree87804b77baf247cbeacbf53b2f856c90f913f00b
parent899f11f9198f2fe1ad2109701f01b92817734f34 (diff)
downloadCMake-77dfbd49b405298e358a1697097eb7a53c4ff217.zip
CMake-77dfbd49b405298e358a1697097eb7a53c4ff217.tar.gz
CMake-77dfbd49b405298e358a1697097eb7a53c4ff217.tar.bz2
Fix for bug #8969, pick a better default version for VS, and make it easier to add new versions of VS to look for.
-rw-r--r--Source/cmake.cxx51
1 files changed, 24 insertions, 27 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index ba16d3b..42ff0db 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -2029,35 +2029,31 @@ int cmake::ActualConfigure()
this->SetGlobalGenerator(new cmGlobalBorlandMakefileGenerator);
#elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(CMAKE_BOOT_MINGW)
std::string installedCompiler;
- std::string mp = "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft"
- "\\VisualStudio\\8.0\\Setup;Dbghelp_path]";
- cmSystemTools::ExpandRegistryValues(mp);
- if (!(mp == "/registry"))
- {
- installedCompiler = "Visual Studio 8 2005";
- }
- else
+ // Try to find the newest VS installed on the computer and
+ // use that as a default if -G is not specified
+ std::string vsregBase =
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\";
+ struct VSRegistryEntryName
+ {
+ const char* MSVersion;
+ const char* GeneratorName;
+ };
+ VSRegistryEntryName version[] = {
+ {"6.0", "Visual Studio 6"},
+ {"7.0", "Visual Studio 7"},
+ {"7.1", "Visual Stuido 7 .NET 2003"},
+ {"8.0", "Visual Studio 8 2005"},
+ {"9.0", "Visual Studio 9 2008"},
+ {"10.0", "Visual Studio 10"},
+ {0, 0}};
+ for(int i =0; version[i].MSVersion != 0; i++)
{
- mp = "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft"
- "\\VisualStudio\\7.1;InstallDir]";
- cmSystemTools::ExpandRegistryValues(mp);
- if (!(mp == "/registry"))
+ std::string reg = vsregBase + version[i].MSVersion;
+ reg += ";InstallDir]";
+ cmSystemTools::ExpandRegistryValues(reg);
+ if (!(reg == "/registry"))
{
- installedCompiler = "Visual Studio 7 .NET 2003";
- }
- else
- {
- mp = "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft"
- "\\VisualStudio\\7.0;InstallDir]";
- cmSystemTools::ExpandRegistryValues(mp);
- if (!(mp == "/registry"))
- {
- installedCompiler = "Visual Studio 7";
- }
- else
- {
- installedCompiler = "Visual Studio 6";
- }
+ installedCompiler = version[i].GeneratorName;
}
}
cmGlobalGenerator* gen
@@ -2067,6 +2063,7 @@ int cmake::ActualConfigure()
gen = new cmGlobalNMakeMakefileGenerator;
}
this->SetGlobalGenerator(gen);
+ std::cout << "-- Building for: " << gen->GetName() << "\n";
#else
this->SetGlobalGenerator(new cmGlobalUnixMakefileGenerator3);
#endif