File: CMP0149.rst

package info (click to toggle)
cmake 4.2.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 152,344 kB
  • sloc: ansic: 403,894; cpp: 303,807; sh: 4,097; python: 3,582; yacc: 3,106; lex: 1,279; f90: 538; asm: 471; lisp: 375; cs: 270; java: 266; fortran: 239; objc: 215; perl: 213; xml: 198; makefile: 108; javascript: 83; pascal: 63; tcl: 55; php: 25; ruby: 22
file content (53 lines) | stat: -rw-r--r-- 2,241 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
CMP0149
-------

.. versionadded:: 3.27

:ref:`Visual Studio Generators` select latest Windows SDK by default.

Visual Studio Generators select a Windows SDK version to put in the
``WindowsTargetPlatformVersion`` setting in ``.vcxproj`` files.
CMake sets the :variable:`CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION`
variable to the selected SDK version.

Prior to CMake 3.27, the SDK version was always selected by the value of
the :variable:`CMAKE_SYSTEM_VERSION` variable.  Users or toolchain files
could set that variable to one of the exact Windows SDK versions available
on the host system.  Since :variable:`CMAKE_SYSTEM_VERSION` defaults to
:variable:`CMAKE_HOST_SYSTEM_VERSION`, and it is not guaranteed that a
matching Windows SDK version is available, CMake had to fall back to
using the latest Windows SDK version if no exact match was available.
This approach was problematic:

* The latest Windows SDK might or might not be selected based on whether
  the host version of Windows happens to match an available SDK version.

* An old Windows SDK version might be selected that has not been updated
  for newer language standards such as C11.

CMake 3.27 and higher prefer to ignore the exact value of
:variable:`CMAKE_SYSTEM_VERSION` and by default select the latest SDK
version available.  An exact SDK version may be specified explicitly
using a ``version=`` field in the :variable:`CMAKE_GENERATOR_PLATFORM`
variable.  See :ref:`Visual Studio Platform Selection`.

This policy provides compatibility for projects, toolchain files, and
build scripts that have not been ported away from using
:variable:`CMAKE_SYSTEM_VERSION` to specify an exact SDK version.

.. note::

  This policy must be set before the first :command:`project` or
  :command:`enable_language` command invocation at the top of the
  project.  That is when :ref:`Visual Studio Generators` select a
  Windows SDK.

The ``OLD`` behavior for this policy is to use the exact value of
:variable:`CMAKE_SYSTEM_VERSION` if possible.  The ``NEW`` behavior
for this policy is to ignore it.

.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.27
.. |WARNS_OR_DOES_NOT_WARN| replace:: does *not* warn
.. include:: include/STANDARD_ADVICE.rst

.. include:: include/DEPRECATED.rst