Imported Upstream version 3.21.4
[platform/upstream/cmake.git] / Help / generator / Visual Studio 17 2022.rst
1 Visual Studio 17 2022
2 ---------------------
3
4 .. versionadded:: 3.21
5
6 Generates Visual Studio 17 (VS 2022) project files.
7
8 Project Types
9 ^^^^^^^^^^^^^
10
11 Only Visual C++ and C# projects may be generated (and Fortran with
12 Intel compiler integration).  Other types of projects (JavaScript,
13 Powershell, Python, etc.) are not supported.
14
15 Instance Selection
16 ^^^^^^^^^^^^^^^^^^
17
18 VS 2022 supports multiple installations on the same machine.
19 The :variable:`CMAKE_GENERATOR_INSTANCE` variable may be set as a
20 cache entry containing the absolute path to a Visual Studio instance.
21 If the value is not specified explicitly by the user or a toolchain file,
22 CMake queries the Visual Studio Installer to locate VS instances, chooses
23 one, and sets the variable as a cache entry to hold the value persistently.
24
25 When CMake first chooses an instance, if the ``VS170COMNTOOLS`` environment
26 variable is set and points to the ``Common7/Tools`` directory within
27 one of the instances, that instance will be used.  Otherwise, if more
28 than one instance is installed we do not define which one is chosen
29 by default.
30
31 Platform Selection
32 ^^^^^^^^^^^^^^^^^^
33
34 The default target platform name (architecture) is that of the host
35 and is provided in the :variable:`CMAKE_VS_PLATFORM_NAME_DEFAULT` variable.
36
37 The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set, perhaps
38 via the :manual:`cmake(1)` ``-A`` option, to specify a target platform
39 name (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
46 Toolset Selection
47 ^^^^^^^^^^^^^^^^^
48
49 The ``v143`` toolset that comes with VS 17 2022 is selected by default.
50 The :variable:`CMAKE_GENERATOR_TOOLSET` option may be set, perhaps
51 via 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