2 issues with Windows SDK version selection
Issue 1
According to the documentation for WINDOWS_TARGET_PLATFORM_VERSION if CMP0149 is set CMake will choose the latest SDK available, provided CMAKE_GENERATOR_PLATFORM does not have a version=
field. This is not working in my GitHub Actions CI builds using Windows. For example the windows-latest image has these SDKs installed:
- 10.0.17763.0
- 10.0.19041.0
- 10.0.20348.0
- 10.0.22000.0
- 10.0.22621.0
CMake always selects 20348 even though CMP0149 is set. I printed ${CMAKE_GENERATOR_PLATFORM}. The value I see is "arm64" with no version=
as you can see in the following so no overriding should be happening.
CMAKE_GENERATOR_PLATFORM="arm64" ; CMAKE_SYSTEM_VERSION="10.0.20348" ; CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION="10.0.20348.0"
This may be a GitHub Actions rather than a CMake problem. I opened issue 8781 in the runner-images repo in case it is.
CMake is picking the latest on my local Windows machine. v3.26 was also doing that.
Issue 2
According to WINDOWS_TARGET_PLATFORM_VERSION if CMP0149 is "enabled" the WindowsSDKVersion
environment variable can be set to an available SDK version which will be selected. This is not working either on Actions CI or on my local machine. Note that the documentation for CMP0149 does not mention this environment variable. Note also the differing language: "enabled" in the former doc vs "new" and "old" used in CMP0149. I am assuming "enabled" == "new".
On my local Windows 11 machine I use the CMake GUI. I used it to add WindowsSDKVersion
to the environment with the value 10.0.22000.0
, deleted the cache and ran configure and generate. CMake still selects 10.0.22621.0
which is the latest on my machine.
On the CI machine I set the variable in the workflow's environment with the value 10.0.22621.0
because there I am trying to work around issue no. 1 and get the latest SDK. Configure is done with CMake on the command line with a new build directory being created. The variable setting has no effect, 20348 is still selected.
Local machine config
CMake: v3.27.7, Windows 11, Generating for Visual Studio 2022 Community Edition.
CI machine config
CMake v3.27.7, Windows Server 2022, Generating for Visual Studio 2022 Enterprise Edition.