# Problem: Differences in detected default WindowsSDK on two different machines

**URL:** https://discourse.cmake.org/t/problem-differences-in-detected-default-windowssdk-on-two-different-machines/2585
**Category:** Usage
**Tags:** os:windows, comp:msvc
**Created:** [January 20, 2021, 9:46am UTC](https://discourse.cmake.org/t/problem-differences-in-detected-default-windowssdk-on-two-different-machines/2585 "2021-01-20T09:46:01Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![sophonet](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/ecccb3/32.png) [@sophonet](https://discourse.cmake.org/u/sophonet)
#### Post date: [January 20, 2021, 9:46am UTC](https://discourse.cmake.org/t/problem-differences-in-detected-default-windowssdk-on-two-different-machines/2585/1 "2021-01-20T09:46:01Z")

</div>

Hi community,

there is a strange behavior when running CMake with the `Visual Studio 15 2017 Win64` generator on two different machines using the same version of Visual Studio 2017 and the same version of CMake (3.19.3):

On one machine, generated vcxproj files contain a line in the “Globals” section `<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>` and the software (onnxruntime) compiles without problems. On the other machine, that line is missing such that Visual Studio 2017 selects 8.1 and compilation fails with an error related to [https://github.com/baldurk/renderdoc/issues/222](https://github.com/baldurk/renderdoc/issues/222).

The source code has exactly the same revision and the CMake flags are identical as well, so I am puzzled about this behavior. The workaround to use `CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION` is not optimal, since Visual Studio, when creating new projects via the IDE also sets the `<WindowsTargetPlatformVersion>` correctly.

So there must be a reason why CMake incorrectly does not set it on that one machine and it would be good to find out why, so any help is appreciated.

Thanks,

sophonet

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [January 20, 2021, 3:11pm UTC](https://discourse.cmake.org/t/problem-differences-in-detected-default-windowssdk-on-two-different-machines/2585/2 "2021-01-20T15:11:19Z")

</div>

I think this means that either the Windows SDKs that are installed are different or that there is some mismatch with the host Windows 10 patch version. @brad.king?

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [January 20, 2021, 3:17pm UTC](https://discourse.cmake.org/t/problem-differences-in-detected-default-windowssdk-on-two-different-machines/2585/3 "2021-01-20T15:17:08Z")

</div>

The code selecting the SDK version is [here](https://gitlab.kitware.com/cmake/cmake/-/blob/v3.19.3/Source/cmGlobalVisualStudio14Generator.cxx#L292-360).

---

<div class="post-metadata">

### Author: ![sophonet](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/ecccb3/32.png) [@sophonet](https://discourse.cmake.org/u/sophonet)
#### Post date: [January 20, 2021, 5:40pm UTC](https://discourse.cmake.org/t/problem-differences-in-detected-default-windowssdk-on-two-different-machines/2585/4 "2021-01-20T17:40:52Z")

</div>

Indeed, that is the case. One version has Windows 10 OS, the other has Windows Server 2012, in which case CMake does not select Windows 10 SDK by default. So the only solution would be to set `CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION`, even though new projects that are created via the VS IDE choose a Windows10SDK (even on Windows Server 2012)? I would assume that the default behavior of CMake should rather follow the VS IDE defaults… What do you think?

Thanks, sophonet.

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [January 20, 2021, 6:00pm UTC](https://discourse.cmake.org/t/problem-differences-in-detected-default-windowssdk-on-two-different-machines/2585/5 "2021-01-20T18:00:09Z")

</div>

> So the only solution would be to set `CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION`

Setting that won’t do anything. It’s meant only for CMake to _report_ what it selected.

> Windows Server 2012, in which case CMake does not select Windows 10 SDK

What is `CMAKE_HOST_SYSTEM_VERSION` on that OS? I suspect it is not 10. CMake by default targets the host’s version.

One can explicitly pass `-DCMAKE_SYSTEM_VERSION=10.0` to tell CMake to target Windows 10.

---

<div class="post-metadata">

### Author: ![sophonet](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/ecccb3/32.png) [@sophonet](https://discourse.cmake.org/u/sophonet)
#### Post date: [January 20, 2021, 8:43pm UTC](https://discourse.cmake.org/t/problem-differences-in-detected-default-windowssdk-on-two-different-machines/2585/6 "2021-01-20T20:43:56Z")

</div>

Thanks guys, for the immediate hints. Indeed, `CMAKE_HOST_SYSTEM_VERSION` is 6.3.9600, matching [https://en.wikipedia.org/wiki/Ver\_(command)](https://en.wikipedia.org/wiki/Ver_(command)).

The trick with `-DCMAKE_SYSTEM_VERSION=10.0` worked, so thanks again, but see my earlier comment above, I think it would make sense that CMake mimics the default behavior of the Visual Studio IDE, and on Windows Server 12, when creating a new project interactively, the Windows SDK is set to 10 even though the host is older. It would be great if this could be implemented in an update.

Thanks,

```
   sophonet
```

---

<div class="post-metadata">

### Author: ![hsattler](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/h/59ef9b/32.png) [@hsattler](https://discourse.cmake.org/u/hsattler)
#### Post date: [January 21, 2021, 5:51am UTC](https://discourse.cmake.org/t/problem-differences-in-detected-default-windowssdk-on-two-different-machines/2585/7 "2021-01-21T05:51:31Z")

</div>

The Visual Studio default might change any time and is mostly a political choice to promote Windows 10. Just as they periodically try to get rid of compatibility with older systems until the developers told them not to. It just happened again with VS2019 16.7 that building 32bit binaries with the 8.1 SDK (needed to build for Windows 7) broke.

I’m not familiar with Xcode but I’m sure it’s the same.

Basing it on the host system is a practical choice to be able to actually run the binaries that you just built. I’d rather have that…
