changing visual studio cmake internal generator

I download Visual Studio 2022 . Inside Visual studio folders , there is CMake folder . The CMake package is installed with Visual Studio 2022 . When I create a new CMake project in Visual Studio 2022 , The Generator is Ninja . It is the internal default generator of Visual Studio CMake . I would like to change Ninja internal default generator to Visual studio 2022 . So that the only internal generator by default is Visual Studio 2022 not Ninja . I am really stuck and cannot find a solution . Any help would be appreciated .

Here are some thoughts:

  1. In my experience, if you build your program from the command line on Windows, from Developer PowerShell for VS22, without specifying any compiler|generator, it will default to Visual Studio’s generator.
  2. -G "Visual Studio 17 2022" for your configure step is a thing
  3. Use CMakePresets. Also, although this repo’s intent is to expose some C++20 Modules stuff, see what it does in its CMakePresets.json file - it explicitly specifies the generator.

I’d suggest option#3. That’s the neatest ever.

On a side note|to be honest, since I discovered CMakePresets, I barely use the IDE itself haha. Only Sublime Text and the command line. I just have to cmake --worfklow --preset <workflow_name> and voila haha. I’d need the IDE for the Debugging convenience, but since I usually have warnings as errors, sanitisers, linters, analysers, etc. enabled, once I finally get to build the program (someday haha), I already went through almost all potential flaws :smile:

Unfortunately , Your reply did not answer my question namely how to change the INTERNAL default generator of CMake . When I open Visual Studio IDE and create a new CMake project , I got an error telling me that the compiler is not found . Changing the CMakeprests.json solves the problem. But when I create a new CMake project inside Visual Studio 2022 I got again the same error . Compiler not found . CMake is not able to recognize Visual Studio as the compiler . For CMake the generator/compiler is Ninja . So is there a way to change this default generator from Ninja to Visual Studio so that avoid this error each time I create a new CMake project inside Visual Studio 2022 NOT in command line

Check the components installed with Visual Studio. They ship everything needed to get it to work.

CMake defaults to the Visual Studio generator itself. This would seem to be some VS setting that defaults to using the Ninja generator.