How to force CMake 3.17 to search for a new generator on Windows 10 when both Visual Studio 15 AND Visual Studio 17 are installed ?

I am trying to upgrade a large Visual Studio library project created using Visual Studio 15 to Visual Studio 17 and can’t get prebuilt CMake 3.17 binaries to search for a new generator.

The problem is that the MSBuild directory still exists at C:\Program Files (x86)\MSBuild\14.0 even after Visual Studio 17 is installed but the new generator is located in C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild. I even tried copying the Visual Studio 17 MSBuild directory to the Visual Studio 14 location with no good results.

If I completely uninstall Visual Studio 15 then CMake complains that it can’t find MSBuild.exe because it is still looking in the old location.

Microsoft claims that Visual Studio 17 has menu choices that will update project files BUT I can’t find them and I’m not sure that they would work anyway since the project files were created by CMake.

I tried MANY things including deleting the CMakeCache.txt file but CMake just recreates it when I run Configure again.

It doesn’t matter if I change the CMAKE_C_COMPILER and CMAKE_CXX_COMPILER to point to the Visual Studio 17 versions or not ?

I even tried removing any Visual Studio environment variables and almost killed other apps that depend on the VCRUNTIME.

So, is there another way to force CMake to search for the new generator ?

Thanks for any help.

Are (Were?) you trying this with a new build tree or trying to reuse an old build tree after upgrading? Changing the compiler like this typically requires a new build tree.