CMP0149.rst 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. CMP0149
  2. -------
  3. .. versionadded:: 3.27
  4. :ref:`Visual Studio Generators` select latest Windows SDK by default.
  5. Visual Studio Generators select a Windows SDK version to put in the
  6. ``WindowsTargetPlatformVersion`` setting in ``.vcxproj`` files.
  7. CMake sets the :variable:`CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION`
  8. variable to the selected SDK version.
  9. Prior to CMake 3.27, the SDK version was always selected by the value of
  10. the :variable:`CMAKE_SYSTEM_VERSION` variable. Users or toolchain files
  11. could set that variable to one of the exact Windows SDK versions available
  12. on the host system. Since :variable:`CMAKE_SYSTEM_VERSION` defaults to
  13. :variable:`CMAKE_HOST_SYSTEM_VERSION`, and it is not guaranteed that a
  14. matching Windows SDK version is available, CMake had to fall back to
  15. using the latest Windows SDK version if no exact match was available.
  16. This approach was problematic:
  17. * The latest Windows SDK might or might not be selected based on whether
  18. the host version of Windows happens to match an available SDK version.
  19. * An old Windows SDK version might be selected that has not been updated
  20. for newer language standards such as C11.
  21. CMake 3.27 and higher prefer to ignore the exact value of
  22. :variable:`CMAKE_SYSTEM_VERSION` and by default select the latest SDK
  23. version available. An exact SDK version may be specified explicitly
  24. using a ``version=`` field in the :variable:`CMAKE_GENERATOR_PLATFORM`
  25. variable. See :ref:`Visual Studio Platform Selection`.
  26. This policy provides compatibility for projects, toolchain files, and
  27. build scripts that have not been ported away from using
  28. :variable:`CMAKE_SYSTEM_VERSION` to specify an exact SDK version.
  29. .. note::
  30. This policy must be set before the first :command:`project` or
  31. :command:`enable_language` command invocation at the top of the
  32. project. That is when :ref:`Visual Studio Generators` select a
  33. Windows SDK.
  34. The ``OLD`` behavior for this policy is to use the exact value of
  35. :variable:`CMAKE_SYSTEM_VERSION` if possible. The ``NEW`` behavior
  36. for this policy is to ignore it.
  37. .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.27
  38. .. |WARNS_OR_DOES_NOT_WARN| replace:: does *not* warn
  39. .. include:: STANDARD_ADVICE.txt
  40. .. include:: DEPRECATED.txt