cmake and Visual Studio generators not find Windows SDK
So, I have both Visual Studio Professional 2017 and 2109 installed (latest version as of today, installed as administrator) and the Windows SDK 10.0.19041.0 (also installed as administrator). Using cmake 3.21.0
. I use
cmake -T v150 -G "Visual Studio 16 2019" -A x64 ..
to invoke cmake with a simple CMakeList.tct file
project(lint_lib)
cmake_minimum_required(VERSION 2.8)
# Turn this on for easier cmake debugging
set(CMAKE_VERBOSE_MAKEFILE OFF)
# Disable color since it makes logs harder to read
set(CMAKE_COLOR_MAKEFILE OFF)
# Relink executables/shared libraries if and only if a library's API changes
set(CMAKE_LINK_DEPENDS_NO_SHARED 1)
# Build type "None" means CMAKE_C_FLAGS or CMAKE_CXX_FLAGS will be used
set(CMAKE_BUILD_TYPE "None")
# Do not allow CMake to add implicit C/C++ libraries
set(CMAKE_C_IMPLICIT_LINK_LIBRARIES "")
set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "")
set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib")
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(CMAKE_C_FLAGS "-std=c99 -Wall -g -fPIC -Dos_LINUX=1")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
set(CMAKE_C_FLAGS "-Wall -g -fPIC")
set(CMAKE_C_FLAGS "-Dos_UNIX=1")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(CMAKE_C_FLAGS "-EHsc -GR /MD /MP /nologo /Zi /GS- /Dos_NT=1")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}")
endif()
but I get this error:
error MSB8036: The Windows SDK version 10.0.19041.0 was not found
I know this is an MSBuild issue, and looking up the issue, it was recommended to install Visual Studio and the Windows SDK as administrator, so I am wondering if cmake is not generating the right Visual Studio projects. That seems to be a little far fetched, because looking at the VCTargetsPath.vcxproj
file generated to check the compiler, I have this
<?xml version="1.0" encoding="UTF-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{F3FC6D86-508D-3FB1-96D2-995F08B142EC}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<Platform>x64</Platform>
<WindowsTargetPlatformVersion>10.0.19041.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props"/>
<PropertyGroup>
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<ConfigurationType>Utility</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v150</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/>
<ItemDefinitionGroup>
<PostBuildEvent>
<Command>echo VCTargetsPath=$(VCTargetsPath)</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/>
</Project>
Any ideas?
Thanks and regards,
Tom