I have just had an interesting issue where I deleted my build folder to recreate everything and CMake has now decided to use my VS 2022 installation as my generator instead of my VS 2022 Preview installation. This led to some compiler errors that I had not seen before because I am using some C++23 features that my VS 2022 install didn’t support yet.
Without deleting my VS2022 install, how can I tell CMake to use my VS2022 Preview install instead?
Any help with this would be appreciated!
I have found the way that i think you are supposed to fix this. I have created a CMakeUserPresets.json file that overrides my configure preset with the following:
This works and makes sure that I am always using the Preview version of VS locally. It would be nice to be able to put some logic into deciding what generator I use though. Like being able to get a list of all installed generators and then iterating through them all until you find one that matches your requirements, or if you don’t you could error stating why none of the generators are suitable.