# VS: Select Windows SDK version

**URL:** https://discourse.cmake.org/t/vs-select-windows-sdk-version/5603
**Category:** Usage
**Tags:** os:windows, comp:msvc, gen:makefiles, gen:vs
**Created:** [May 3, 2022, 9:53am UTC](https://discourse.cmake.org/t/vs-select-windows-sdk-version/5603 "2022-05-03T09:53:00Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![flaviu2](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/f/74df32/32.png) [@flaviu2](https://discourse.cmake.org/u/flaviu2)
#### Post date: [May 3, 2022, 9:53am UTC](https://discourse.cmake.org/t/vs-select-windows-sdk-version/5603/1 "2022-05-03T09:53:00Z")

</div>

I have Win10 64 bit, and VS2017. I have a **CMakeLists.txt** and a **Makefile** which looks like this:

```auto
build/Makefile:	CMakeLists.txt
	mkdir -p build; \
	cd build; \
	cmake ../ -DCMAKE_TOOLCHAIN_FILE=~/github/vcpkg/scripts/buildsystems/vcpkg.cmake

clean:
	rm -rf build/

```

When I run make, I got:

```auto
    Build started 5/3/2022 12:36:26 PM.
    Project "C:\Project\MyProject\build\CMakeFiles\3.21.1\VCTargetsPath.vcxproj" on node 1 (default targets).
    C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.Cpp.WindowsSDK.targets(46,5): error MSB8036: The Windows SDK version 8.1 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution". [C:\Project\MyProject\build\CMakeFiles\3.21.1\VCTargetsPath.vcxproj]
    Done Building Project "C:\Project\MyProject\build\CMakeFiles\3.21.1\VCTargetsPath.vcxproj" (default targets) -- FAILED.

    Build FAILED.

    "C:\Project\MyProject\build\CMakeFiles\3.21.1\VCTargetsPath.vcxproj" (default target) (1) ->
    (_CheckWindowsSDKInstalled target) ->
      C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.Cpp.WindowsSDK.targets(46,5): error MSB8036: The Windows SDK version 8.1 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution". [C:\Project\MyProject\build\CMakeFiles\3.21.1\VCTargetsPath.vcxproj]

        0 Warning(s)
        1 Error(s)

    Time Elapsed 00:00:00.33

  Exit code: 1

```

My question is: how can I setup my current platform toolset, which is **10.0.17763.0**?

---

<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: [May 3, 2022, 11:36am UTC](https://discourse.cmake.org/t/vs-select-windows-sdk-version/5603/2 "2022-05-03T11:36:18Z")

</div>

You can pass `-T` to select a toolset for the Visual Studio generators. We pass `v143,version=14.31.31103` for one of our CI builds. I feel like `10.0.17763.0` is an SDK version, not a toolchain version (unless you’re using a VS2010-era toolchain?). You might just be missing the right SDK selection in the VS installer.

---

<div class="post-metadata">

### Author: ![flaviu2](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/f/74df32/32.png) [@flaviu2](https://discourse.cmake.org/u/flaviu2)
#### Post date: [May 4, 2022, 2:21pm UTC](https://discourse.cmake.org/t/vs-select-windows-sdk-version/5603/3 "2022-05-04T14:21:09Z")

</div>

Yes, that number, 10.0.17763.0, it’s Windows SDK version:

![image](https://discourse.cmake.org/uploads/default/original/2X/e/e0ee229082c68fea252d86f5fd59b333b912ba3f.png)

I’ll try what you said, to put my SDK version using **-T** option, first, I need to figure out where should I put this option … right now I have:

**CMakeLists.txt** and **Makefile** files only, **CMakeCache.txt** it’s generated.

I’m not cmake advanced 😃

---

<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: [May 4, 2022, 5:37pm UTC](https://discourse.cmake.org/t/vs-select-windows-sdk-version/5603/4 "2022-05-04T17:37:53Z")

</div>

The command I gave needs to know the _toolchain_ version. I’m not actually sure how to specify the SDK version to CMake off hand… @brad.king?

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [May 5, 2022, 11:58am UTC](https://discourse.cmake.org/t/vs-select-windows-sdk-version/5603/5 "2022-05-05T11:58:17Z")

</div>

I think you want to set `CMAKE_SYSTEM_VERSION` to `10.0.17763.0`, but I’m not sure if you will also need to set `CMAKE_SYSTEM_NAME` to something as well. Ordinarily, you would set variables like these in your toolchain file, but I see that you’re using vcpkg’s toolchain file. I think that supports being able to pass in another toolchain file to chain along to, but you’d have to look up how to do that. Alternatively, you might be able to get away with setting these variables on the `cmake` command line using something along the lines of `cmake -DCMAKE_SYSTEM_VERSION=10.0.17763.0 ...`

---

<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: [May 5, 2022, 2:32pm UTC](https://discourse.cmake.org/t/vs-select-windows-sdk-version/5603/6 "2022-05-05T14:32:44Z")

</div>

Yes, [CMAKE\_SYSTEM\_VERSION](https://cmake.org/cmake/help/v3.23/variable/CMAKE_SYSTEM_VERSION.html#system-version-for-host-builds) can be set on host builds to select the Windows SDK version with VS generators. Running `cmake -DCMAKE_SYSTEM_VERSION=10.0.17763.0 ...` should work.

---

<div class="post-metadata">

### Author: ![flaviu2](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/f/74df32/32.png) [@flaviu2](https://discourse.cmake.org/u/flaviu2)
#### Post date: [May 11, 2022, 8:52am UTC](https://discourse.cmake.org/t/vs-select-windows-sdk-version/5603/7 "2022-05-11T08:52:43Z")

</div>

Even if I got another errors, I guess my reported issue has been solved:

```auto
C:\Project\my-project>make
mkdir -p build; \
        cd build; \
        cmake ../ -DCMAKE_TOOLCHAIN_FILE=C:/Project/vcpkg/scripts/buildsystems/vcpkg.cmake
-- Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.19044.
-- The CXX compiler identification is MSVC 19.16.27045.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe - broken
CMake Error at C:/Home/Flaviu/cmake-3.21.1-windows-x86_64/share/cmake-3.21/Modules/CMakeTestCXXCompiler.cmake:62 (message):
  The C++ compiler

    "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe"

  is not able to compile a simple test program.

```

Note: **Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.19044.**

So, I thank you for your assistance and implication !

---

<div class="post-metadata">

### Author: ![flaviu2](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/f/74df32/32.png) [@flaviu2](https://discourse.cmake.org/u/flaviu2)
#### Post date: [May 11, 2022, 9:13am UTC](https://discourse.cmake.org/t/vs-select-windows-sdk-version/5603/8 "2022-05-11T09:13:49Z")

</div>

BTW, commenting the following line:

`set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")`

into my **CMakeLists.txt** got me into generating successfully the solution. In case anyone need it.

---

<div class="post-metadata">

### Author: ![stavbodik](https://discourse.cmake.org/user_avatar/discourse.cmake.org/stavbodik/32/3440_2.png) [@stavbodik](https://discourse.cmake.org/u/stavbodik)
#### Post date: [May 15, 2023, 9:50am UTC](https://discourse.cmake.org/t/vs-select-windows-sdk-version/5603/9 "2023-05-15T09:50:13Z")

</div>

"The `CMAKE_SYSTEM_VERSION` should be set on the command line on the _first_ configuration of a new build tree ( **cmake-gui has options to add it as a cache entry before configuring** ). "

 ![entry](https://discourse.cmake.org/uploads/default/original/2X/3/39c2e553b08243e069b66afe59f06cf3d00fb466.png)

Thanks to [Brad King](https://gitlab.kitware.com/brad.king)

posted here :

[https://gitlab.kitware.com/cmake/cmake/-/issues/16713](https://gitlab.kitware.com/cmake/cmake/-/issues/16713)
