Poniżej CMake od wersji 2.8.4 (Źródło: cmake.cxx: począwszy linia 2039):
// 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 Studio 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++)
{
std::string reg = vsregBase + version[i].MSVersion;
reg += ";InstallDir]";
cmSystemTools::ExpandRegistryValues(reg);
if (!(reg == "/registry"))
{
installedCompiler = version[i].GeneratorName;
}
}
cmGlobalGenerator* gen
= this->CreateGlobalGenerator(installedCompiler.c_str());
if(!gen)
{
gen = new cmGlobalNMakeMakefileGenerator;
}
this->SetGlobalGenerator(gen);
std::cout << "-- Building for: " << gen->GetName() << "\n";
Wydaje się, że CUpewnij patrzy w rejestrze systemu Windows, aby określić, które generator użyć. Przeszukuje podklucze rejestru Visual Studio (6.0, 7.0, itd.) W pozycji [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\
dla wpisu o nazwie InstallDir
. Jeśli zostanie znaleziony, używa odpowiedniego generatora. (Będzie używać najnowszej dostępnej wersji Visual Studio.) W przeciwnym razie używa generatora NMake.
Uwaga: wpis InstallDir
nie zawsze występuje, nawet jeśli zainstalowana jest konkretna wersja programu Visual Studio. Może to mieć związek z ustawieniami instalacji lub konkretną wersją Visual Studio (np. Wydaje się, że wersje "Express" Visual C++ nie dodają tego wpisu.)
Oczywiście możliwe jest przesłonięcie wartości domyślnej ustawiając przez dodanie -G {Generator Name}
na końcu polecenia CMake.
Czy to ta sama wersja programu CMake? – rubenvb
Tak, wersja 2.8.4 na obu komputerach. – cfinley
Naprawdę znalazłem rozwiązanie, ale nie pozwolę sobie na jego publikację przez kolejne siedem godzin ... <. < – cfinley