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.
cmake (path to project dir)
cmake -G ‘Visual Studio 16 2019’ -A x64 (path to project dir)
Have a look at the environment variable CMAKE_GENERATOR.
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.