1

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

harish
  • 1,486
  • 2
  • 16
  • 24

1 Answers1

2

You can pass the required version via CLI:

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

See also CMAKE_GENERATOR_TOOLSET variable.

zaufi
  • 6,284
  • 25
  • 33
  • thanks! I did try various combinations with -T (y -T v142.xx.yy or -T 14.24) but seems all of those were incorrect. This worked perfectly! – harish Jun 09 '20 at 11:53