VS: Select latest available Windows SDK version by default
Add policy CMP0149
to stop preferring SDKs exactly matching CMAKE_SYSTEM_VERSION
over the latest SDK. See the policy documentation for motivation.
Add a version=
field to CMAKE_GENERATOR_PLATFORM
to explicitly control the SDK version selection without relying on CMAKE_SYSTEM_VERSION
. Allow this field to be set to either an exact SDK version, or in VS 2019+, to just 10.0
to let VS select an exact version.
If no explicit version=
field is specified, check the WindowsSDKVersion
environment variable established by vcvarsall.bat
or similar scripts. This is similar to how we check a VS##0COMNTOOLS
environment variable to select a CMAKE_GENERATOR_INSTANCE
for VS.
Fixes: #16202 (closed), #16713 (closed), #17992 (closed), #21403 (closed)