1Visual Studio 17 2022
2---------------------
3
4.. versionadded:: 3.21
5
6Generates Visual Studio 17 (VS 2022) project files.
7
8Project Types
9^^^^^^^^^^^^^
10
11Only Visual C++ and C# projects may be generated (and Fortran with
12Intel compiler integration).  Other types of projects (JavaScript,
13Powershell, Python, etc.) are not supported.
14
15Instance Selection
16^^^^^^^^^^^^^^^^^^
17
18VS 2022 supports multiple installations on the same machine.
19The :variable:`CMAKE_GENERATOR_INSTANCE` variable may be set as a
20cache entry containing the absolute path to a Visual Studio instance.
21If the value is not specified explicitly by the user or a toolchain file,
22CMake queries the Visual Studio Installer to locate VS instances, chooses
23one, and sets the variable as a cache entry to hold the value persistently.
24
25When CMake first chooses an instance, if the ``VS170COMNTOOLS`` environment
26variable is set and points to the ``Common7/Tools`` directory within
27one of the instances, that instance will be used.  Otherwise, if more
28than one instance is installed we do not define which one is chosen
29by default.
30
31Platform Selection
32^^^^^^^^^^^^^^^^^^
33
34The default target platform name (architecture) is that of the host
35and is provided in the :variable:`CMAKE_VS_PLATFORM_NAME_DEFAULT` variable.
36
37The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set, perhaps
38via the :manual:`cmake(1)` ``-A`` option, to specify a target platform
39name (architecture).  For example:
40
41* ``cmake -G "Visual Studio 17 2022" -A Win32``
42* ``cmake -G "Visual Studio 17 2022" -A x64``
43* ``cmake -G "Visual Studio 17 2022" -A ARM``
44* ``cmake -G "Visual Studio 17 2022" -A ARM64``
45
46Toolset Selection
47^^^^^^^^^^^^^^^^^
48
49The ``v143`` toolset that comes with VS 17 2022 is selected by default.
50The :variable:`CMAKE_GENERATOR_TOOLSET` option may be set, perhaps
51via the :manual:`cmake(1)` ``-T`` option, to specify another toolset.
52
53.. |VS_TOOLSET_HOST_ARCH_DEFAULT| replace::
54   By default this generator uses the 64-bit variant on x64 hosts and
55   the 32-bit variant otherwise.
56
57.. include:: VS_TOOLSET_HOST_ARCH.txt
58