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:
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?
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.
For anyone else who finds themselves here, baffled, replace the "-G “Visual Studio 15 2017” or -G “Visual Studio 16 2019” option with -T v142. It will say “Building for: Visual Studio 17 2022” BUT when you open the .sln file it will say “Visual Studio 2019” and the toolset will be set to 2019.
Yet, I’m facing right now troubles with ExternalProject_Add(), with CMake 3.31.6.
I have Visual Studio 2022, and with Visual Studio Installer, installed “MSVC v141 - VS 2017”.
In the call to ExternalProject_Add(), I added:
CMAKE_GENERATOR_TOOLSET v141
CMAKE_GENERATOR_TOOLSET "v141"
-DCMAKE_GENERATOR_TOOLSET:STRING=v141
but in the cache, I always get:
//Name of generator toolset.
CMAKE_GENERATOR_TOOLSET:INTERNAL=
I also added to the call to the CMake command the switch -T v141, but no more success.