# How does CMAKE\_VS\_WINDOWS\_TARGET\_PLATFORM\_VERSION work?

**URL:** https://discourse.cmake.org/t/how-does-cmake-vs-windows-target-platform-version-work/260
**Category:** Code
**Created:** [November 26, 2019, 1:22pm UTC](https://discourse.cmake.org/t/how-does-cmake-vs-windows-target-platform-version-work/260 "2019-11-26T13:22:19Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![djspringate](https://discourse.cmake.org/user_avatar/discourse.cmake.org/djspringate/32/193_2.png) [@djspringate](https://discourse.cmake.org/u/djspringate)
#### Post date: [November 26, 2019, 1:22pm UTC](https://discourse.cmake.org/t/how-does-cmake-vs-windows-target-platform-version-work/260/1 "2019-11-26T13:22:19Z")

</div>

CMAKE\_VS\_WINDOWS\_TARGET\_PLATFORM\_VERSION

I’m running Windows 10 Home 1903 (OS Build 18362.46).  
My C:\Program Files (x86)\Windows Kits\10\Lib folder contains:  
10.0.16299.0  
10.0.17134.0  
10.0.17763.0

No matter what I do, CMAKE\_VS\_WINDOWS\_TARGET\_PLATFORM\_VERSION, returns 10.0.16299.0.

Surely, it should pick the highest version? What is the expected behaviour for this?  
How is it supposed to work? This has been driving me nuts for a long time and only now have I realised I should be posting this here ^^

Thanks in advance for any help!

---

<div class="post-metadata">

### Author: ![robert.maynard](https://discourse.cmake.org/user_avatar/discourse.cmake.org/robert.maynard/32/4_2.png) [@robert.maynard](https://discourse.cmake.org/u/robert.maynard)
#### Post date: [November 26, 2019, 2:18pm UTC](https://discourse.cmake.org/t/how-does-cmake-vs-windows-target-platform-version-work/260/2 "2019-11-26T14:18:34Z")

</div>

This variable reports what Windows SDK is being targeted by the current build. Setting this variable has no effect, instead what you need to do is specify an explicit `CMAKE_SYSTEM_VERSION` when configuring a project for the first time.

I believe the reason that `10.0.16299.0` is being selected is that you might only have the runtime files for the other SDK’s and not the development headers.

---

<div class="post-metadata">

### Author: ![djspringate](https://discourse.cmake.org/user_avatar/discourse.cmake.org/djspringate/32/193_2.png) [@djspringate](https://discourse.cmake.org/u/djspringate)
#### Post date: [November 26, 2019, 5:14pm UTC](https://discourse.cmake.org/t/how-does-cmake-vs-windows-target-platform-version-work/260/3 "2019-11-26T17:14:48Z")

</div>

Hi Rob,

Thanks for the suggestions.  
I checked and I have a whole bunch of headers under C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0 etc.

What are valid settings for CMAKE\_SYSTEM\_VERSION?  
Something like SET( CMAKE\_HOST\_SYSTEM\_VERSION 10.0.17763.0) ?  
(I can’t check right now as I’m away from my dev PC)

---

<div class="post-metadata">

### Author: ![robert.maynard](https://discourse.cmake.org/user_avatar/discourse.cmake.org/robert.maynard/32/4_2.png) [@robert.maynard](https://discourse.cmake.org/u/robert.maynard)
#### Post date: [November 26, 2019, 6:00pm UTC](https://discourse.cmake.org/t/how-does-cmake-vs-windows-target-platform-version-work/260/4 "2019-11-26T18:00:05Z")

</div>

This isn’t my area of expertise but I believe it is specified via `CMAKE_SYSTEM_VERSION` and some logic internal to CMake.

@brad.king Is this correct?

---

<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: [November 26, 2019, 6:12pm UTC](https://discourse.cmake.org/t/how-does-cmake-vs-windows-target-platform-version-work/260/5 "2019-11-26T18:12:06Z")

</div>

`CMAKE_HOST_SYSTEM_VERSION` is always computed automatically from the real host version.

A toolchain file can

```cmake
set(CMAKE_SYSTEM_VERSION 10.0)

```

The value `10.0` tells CMake to look for the largest available Windows SDK version. Or one can use any four-component version corresponding to a directory like `C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0`, e.g.

```cmake
set(CMAKE_SYSTEM_VERSION 10.0.17763.0)

```

If building for a Windows target and the only thing you want to do is select the SDK version, you don’t need a toolchain file and can just define `CMAKE_SYSTEM_VERSION` on the command line, e.g.

```auto
cmake ../src -DCMAKE_SYSTEM_VERSION=10.0.17763.0

```
