CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM does not affect VisualStudio 15 2017 project files
I'm trying to set Windows sdk version to an appropriate value in the following environment:
- OS: Windows 10.0
- CMake version: 3.19.3
- Generator: Visual Studio 15 2017 Win64
- Installed SDK-s: 10.0.10240.0, 10.0.10586.0, 10.0.14393.0, 10.0.15063.0, 10.0.16299.0, 10.0.17134.0, 10.0.17763.0
I have set CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM
before the first call of project()
to 10.0.17134.0 but it does not have any effect, the used version is always the most recent one: 10.0.17763.0.
I have checked the cmGlobalVisualStudio14Generator
and the cmGlobalVisualStudioVersionedGenerator
classes and disovered the following behavior:
- the main part of the logic finding the required windows SDK version is here
cmGlobalVisualStudio14Generator::GetWindows10SDKVersion
- at some point this calls
std::string maxVersion = this->GetWindows10SDKMaxVersion(mf);
- implementation of
GetWindows10SDKMaxVersion
has a non-dummy implementation incmGlobalVisualStudio14Generator
... - ...but it is overridden in
cmGlobalVisualStudioVersionedGenerator
and that returns an empty string - thus the
cmGlobalVisualStudio14Generator::GetWindows10SDKVersion
function does not remove available SDK versions above the requried maximum.
Is that the required behavior? If so, how can I select a Windows SDK in the formerly mentioned environment?
If I remove the overriden dummy behavior of GetWindows10SDKMaxVersion
from cmGlobalVisualStudioVersionedGenerator
everything works well in my environment.
These commits are related: ba497111 83ddc4d2
The behavior was the same with cmake-3.14, but I did not check the code.