Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the default MSVC compiler version when multiple versions exist for same toolset version

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.

VS build tools

like image 963
harish Avatar asked Nov 03 '25 16:11

harish


1 Answers

You can pass the required version via CLI:

$ cmake ... -T v142,version=14.24

See also CMAKE_GENERATOR_TOOLSET variable.

like image 169
zaufi Avatar answered Nov 06 '25 09:11

zaufi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!