Setting Default Generators

Is there a way to set default generators for your project? I haven’t seen any such functionality but it would be hugely beneficial to be able to do this.
Example:
cmake (path to project dir)

Vs
cmake -G ‘Visual Studio 16 2019’ -A x64 (path to project dir)

Have a look at the environment variable CMAKE_GENERATOR.

1 Like

Does that work if it’s set from within a CMakeLists.txt file? My understanding is that you’d have to generate a project, where that would then be set and regenerate the desired project. Is this true?

You cannot set the generator from inside the project. The generator is chosen by the user, not the upstream developer. The most you could do is issue a message(FATAL_ERROR) if the generator is not supported.

1 Like