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
This commit is contained in:
Piyush Aggarwal 2021-06-16 17:09:55 +05:30
parent c0cbcc0d36
commit f33fed6fa1

View file

@ -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()