Using "Visual Studio 15 2017" compiler in Visual Studio 2022 IDE - visual-studio

I have recently downloaded the Visual Studio 2022 IDE. During installation, I selected "Desktop development with C++" and "MSVC v141 - VS 2017 C++ x64/x86 build tools" (as answers to similar questions had suggested). I want to compile using cmake -G "Visual Studio 15 2017 Win64" .. but get the following error:
CMake Error at CMakeLists.txt:83 (project):
Generator
Visual Studio 15 2017 Win64
could not find any instance of Visual Studio.
cmake --help returns a list of available generators (shortened for readability):
The following generators are available on this platform (* marks default):
* Visual Studio 17 2022 = Generates Visual Studio 2022 project files.
Use -A option to specify architecture.
Visual Studio 16 2019 = Generates Visual Studio 2019 project files.
Use -A option to specify architecture.
Visual Studio 15 2017 [arch] = Generates Visual Studio 2017 project files.
Optional [arch] can be "Win64" or "ARM".
...
This output makes me think that Visual Studio 15 2017 should be available, but it is nevertheless not being found.
cmake --version returns cmake version 3.23.22060601-MSVC_2.
How could I use the Visual Studio 15 2017 generator instead of the newest Visual Studio 17 2022?

How could I use the Visual Studio 15 2017 generator instead of the newest Visual Studio 17 2022?
Answering this directly: find and install Visual Studio 2017. That's a bad solution, though.
I selected "Desktop development with C++" and "MSVC v141 - VS 2017 C++ x64/x86 build tools" (as answers to similar questions had suggested)
Ah, so you want to target MSVC v141. No problem. Use the generator for the toolchain you already have installed (VS2022) and then tell it to use the v141 toolset with the -T flag, like so:
cmake -G "Visual Studio 17 2022" -T v141 [...other args...]

Related

Where are official build system generator name mentioned for different versions of Microsoft Visual Studio for CMake?

Lot of open source softwares use CMake for generating build files for build automation. Generally we do like
mkdir build
cd build
cmake .. -G"Visual Studio 15 2017" -A x64"
Here we are passing Visual Studio 15 2017 as build system generator name.
Different project recommend different versions of Visual Studio. I could not find these names for different versions on CMake documentation.
For example for Visual Studio 2019 generator name is Visual Studio 16 2019
Where can I find these names for -G option for different version or How can I construct generator name myself?

Visual Studio 2019 won't compile any C# project after Visual Studio 2017 uninstall

I uninstalled Visual Studio 2017, then installed Visual Studio 2019.
Visual Studio 2019 doesn't compile any C# project, even if I make a completely new one, with this error:
The specified task executable location "c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Roslyn\csc.exe" is invalid.
I can't find where this path is stored. How can I fix it?

Visual Studio 2015 Installer doesn't install cl.exe

I had installed Visual Studio 2017 on my machine with VC2015.3 C++ compiler toolset. The VC14 compiler is now located in C:\Program Files (x86)\Microsoft Visual Studio\Shared\14.0\VC\bin\cl.exe
Now, when I install Visual Studio 2015 and select to install "Common Tools for Visual C++ 2015" there is no cl.exe in C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin as expected and as it always have been.
It's just like the installer "know" that I have already VC14 compiler installed (through VS2017) and skips it completely.
What is the issue here?

Cannot build Boost with Visual Studio 2017

I downloaded Boost 1.63.0 and tried building it with my newly installed Visual Studio 2017 but there is no way it works! It compiles with the Visual Studio 2015 compiler instead.
Let me be more clear. I have both Visual Studio 2015 Update 3 and Visual Studio 2017 installed in my laptop. I open a command prompt with the environment set for the 2017 compiler (which is version 15.0).
Then I execute:
b2 --layout=versioned --with-chrono
but it uses version 14.0 (toolset=msvc-14.0) instead of version 15.0...
Thanks!
Juan Dent

CMake Visual Studio Differences?

When I went to compile a project with CMake using MSVC++, I noticed something. CMake asked me to identify which copy of Visual Studio I wanted to use, and it presented me with the choices:
Visual C++ 2010
Visual C++ 10
Visual C# 2010
Visual C# 10
What is the difference between 2010 and 10?
The internal version number for VS2010 is version 10. Lucky coincidence. Version 11 won't be on your machine until 2012. Or later.
For creating a VS2010 project and compiling it from cmd, these are the options you could use:
cmake -G "Visual Studio 11 Win64" "%myProject%\src"
CD %HOMEDRIVE%\Windows\Microsoft.NET\Framework64\v4.0.30319
msbuild %myProject%\build\ALL_BUILD.vcxproj /detailedsummary /property:PlatformToolset=v110 /p:TargetFrameworkVersion=v4.5.1 /clp:ErrorsOnly /p:Configuration=Debug
msbuild %myProject%\build\ALL_BUILD.vcxproj /detailedsummary /property:PlatformToolset=v110 /p:TargetFrameworkVersion=v4.5.1 /clp:ErrorsOnly /p:Configuration=Release

Resources