Can the VS 2019 generator be used if only VS2022 is installed?

If Visual Studio 2022 is installed, including the older Toolset V142, and NO VS2019 is installed, can the ‘Visual Studio 16 2019 Generator’ be used, to create a solution targeting the old toolset?

Our large application is currently stuck on CMake 3.15.x, however our team is migrating to Visual Studio 2022. Until now we’ve kept the buildscripts locked to VS Toolset 142 and haven’t had a problem. Now we have our first developer whose installed VS2022 with no Visual Studio 2019 present and gets an error:

CMake Error at CMakeLists.txt:89 (project):
  Generator

    Visual Studio 16 2019

  could not find any instance of Visual Studio.

Before firing CMake, our build scripts run these two tools:

%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe
%FoundVsInstallDir%\VC\Auxiliary\Build\vcvarsall.bat

After tweaking the build-scripts, I realized even on my machine ‘vswhere.exe’ is now detecting a VS 2022 Enterprise on D:\ first, but CMake is using VS2019 in the default location. I can’t see how CMake is selecting that.

If we can’t upgrade CMake at this time, is having VS2019 installed simply for the GENERATOR a forced requirement?

Yes. Note that VS2022 does have components for VS2019 toolchains last I checked, so you can use the VS2022 generator with the known-good toolchain.

Thanks for confirming it should be possible. I will investigate further and post back if the solution isn’t specific to our stuff. I’ve recreated the error message on a 2nd machine, but it’s still not fully configured yet either.