Cannot set toolset when configuring with the Visual Studio 2022 generator.

I have installed on my machine Visual Studio 2022 17.9 with the MSVC toolsets 14.36, 14.38 and 14.39. I created with Visual Studio a new “CMake project” and after configuring it with cmake -S . -B build -G "Visual Studio 17 2022" I noticed that CMake is choosing MSVC 14.36; the oldest one.

I tried to manually choose the latest toolset by passing -T v143,version=14.39 but every time it fails with No CMAKE_C/CXX_COMPILER could be found.. I tried the same while under the Visual Studio developer Powershell (both with and without specifying -vcvars_ver=14.39) but the result has been either failure to find the compiler, or finding 14.36.

Am I doing something wrong? Thanks.

1 Like

@brad.king Is this the Visual Studio toolchain bug?

VS 17’s v143 minor toolsets 14.36 through 14.39 cannot be used by -T version= due to a bug in VS. See VS Developer Community feedback item 10385615 and CMake Issue 25192.

In the Visual Studio Installer’s section for VS 17.9, look under Desktop development with C++ and make sure the MSVC v143 - VS 2022 C++ x64/x86 build tools (Latest) component is installed. If installed, CMake should choose that by default.

I gave it another try and it printed The CXX compiler identification is MSVC 19.38.33135.0. The following components are installed:

image

Please look for a file

C:/Program Files/Microsoft Visual Studio/2022/*/VC/Auxiliary/Build/Microsoft.VCToolsVersion.default.txt

where * depends on the VS edition (Preview, Community, Professional, or Enterprise). What does it contain?

14.39.33519

BTW there is also a Microsoft.VCToolsVersion.v143.default.txt file that contains 14.38.33130.

If those two files disagree something may be wrong with the VS installation. Try removing the “Latest” component I mentioned above and then installing it again.

I reinstalled the “Latest” component and installed it again. The files are still different.

I am going to reinstall Visual Studio…

On reinstall, select the “Latest” toolchain but don’t install any of the minor toolchains yet. Let’s make sure the basic usage works first.

Sorry to bother that old post.
However, I receive nearly the same error with Visual Studio 2022 17.11 Preview2 with the latest build tools of v143. This looks like the VCTargetPath is incorrect, and due to that CompilerIdCXX.proj does not compile at all. Even more, somehow that project was generate with <Import Project="C:/Program Files/Microsoft Visual Studio/2022/Preview\VC\Auxiliary\Build\14.41.33923\Microsoft.VCToolsVersion.14.41.33923.props" />

While I do not have that file, and just have C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Auxiliary\Build folder filled with .props items

Running CMake 3.30.0-rc3 with -G "Visual Studio 17 2022" and no -T argument works fine for VS 17.11p2 for me. Adding -T 14.41 gets an error, which I’m addressing in CMake MR 9622.

1 Like