What is the default generator for CMake in Windows?

Viewed 19199

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.

2 Answers

For posterity.

TLDR: CMake 3.15 and above uses the environment variable CMAKE_GENERATOR as the default generator, it'll be used by cmake if no -G option provided. Or if it was an invalid generator CMake will choose its internal default generator.

CMake has introduced an environment variable CMAKE_GENERATOR controlling the default generator in version 3.15, see this CMake 3.15 Release Notes.

And the document for the environment variable CMAKE_GENERATOR.

Related