From f33fed6fa1f6a2359d49a614b741acb910a28015 Mon Sep 17 00:00:00 2001 From: Piyush Aggarwal Date: Wed, 16 Jun 2021 17:09:55 +0530 Subject: [PATCH] windows: fix support for WIN_SDK < 19041 inspired by : https://gitlab.kitware.com/cmake/cmake/-/blob/v3.17.3/Modules/InstallRequiredSystemLibraries.cmake#L339-358 Since CMake doesn't really has a way of providing the Win10 SDK's version ( see: https://gitlab.kitware.com/cmake/cmake/-/issues/20773 ) we read the XML file set up by the SDK and filter the SDK version out of it --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 27ed1d798..3c5e2958a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,7 +101,11 @@ if (KF5_OPTIONAL_COMPONENTS) endif() if (WIN32) - string(REGEX MATCH "[0-9][0-9][0-9][0-9][0-9]" WIN_SDK_VERSION "${CMAKE_SYSTEM_VERSION}" ) + get_filename_component(WINDOWS_KITS_DIR + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot10]" ABSOLUTE) + file(READ "${WINDOWS_KITS_DIR}/SDKManifest.xml" SDK_MANIFEST) + string(REGEX MATCH "PlatformIdentity[^\n]*" PLATFORM_IDENTITY "${SDK_MANIFEST}" ) + string(REGEX MATCH "[0-9][0-9][0-9][0-9][0-9]" WIN_SDK_VERSION "${PLATFORM_IDENTITY}" ) add_compile_definitions(WIN_SDK_VERSION=${WIN_SDK_VERSION}) endif()