When running CMake on one PC, CMake generates NMake files by default. On another, it generates a Visual Studio project.
I know I can override the default by adding -G "NMake Makefiles"
to the end of my CMake statement, but I want to know why it defaults to Visual Studio projects on one and NMake files on another.
The following is from the CMake Source (version 2.8.4: cmake.cxx: starting line 2039):
It appears that CMake looks at the Windows Registry to determine which generator to use. It searches the Visual Studio registry subkeys (6.0, 7.0, etc) in
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\
for an entry calledInstallDir
. If one is found, it uses the corresponding generator. (It will use the newest version of Visual Studio available.) Otherwise, it uses the NMake generator.Note that the
InstallDir
entry is not always present, even when a particular version of Visual Studio is installed. This may have to do with installation settings or a particular version of Visual Studio (e.g. it seems that the "Express" versions of Visual C++ do not add this entry.)It is, of course, possible to override the default setting by appending
-G {Generator Name}
to the end of your CMake command.