MS VC 2012 can build x64 binaries using the VS 2013 generator but not the VS 2022 generator
I use cmake to automatically build executables with a variety of MS Visual C++ versions. Recently, a number of generators for older versions of MSVC were deprecated or removed. So I've been trying to change my project to use newer generators. I'm building on Microsoft's hosted Azure VMs, which have a native copy of VS 2022. So that seemed like a natural choice.
Using the VS 2022 generator works for everything I tried except for Visual Studio 2012. Specifically on VS 2012, when building a x86 (32-bit) binary, it does not matter if I use the VS 2013 generator or 2022 generator; both work. But building a x64 (64-bit) binary only works with the VS 2013 generator. The 2022 generator results in a "No CMAKE_CXX_COMPILER could be found." error message.
I have an Azure build here that demonstrates the issue.
Success | Generator | Architecture | Link |
---|---|---|---|
Yes | VS 2022 | x86 | link |
No | VS 2022 | x64 | link |
Yes | VS 2013 | x86 | link |
Yes | VS 2013 | x64 | link |
I think that this is a bug and that it should be possible for the VS 2022 generator to build in this instance. The documentation for the removed VS 2012 generator says:
Removed. This once generated Visual Studio 11 2012 project files, but the generator has been removed since CMake 3.28. It is still possible to build with VS 11 2012 tools using the Visual Studio 14 2015 (or above) generator with CMAKE_GENERATOR_TOOLSET set to v110, or by using the NMake Makefiles generator.
So based on that, I would expect the VS 2022 generator to work.
(I'm not sure why I tried using the 2013 Generator...)