I have multiple versions of MSVC C++ build tools for the same toolset(v142) installed using Visual studio build tools. How can I set the default or preferred version of the MSVC compiler. Is there a registry or environment variable for setting this in Windows or with Cmake?
Cmake picks up the latest version and I want it to use older version for some builds. CMake does seem to have a -T parameter for toolset but in my case both versions are for toolset v142.
Please note that I do not have or intend to use Visual Studio IDE for this since I am dealing with command line builds for CI purposes.

You can pass the required version via CLI:
$ cmake ... -T v142,version=14.24
See also CMAKE_GENERATOR_TOOLSET variable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With