Manually define CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION (#24343)

### Details:
`CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION` is supposed to be set by
CMake when Windows SDK is installed in the system, but it works only for
Visual Studio generators. As we use Ninja, we set this variable
manually, trying to mimic the default behavior.
This commit is contained in:
Andrey Babushkin 2024-05-02 16:50:48 +01:00 committed by GitHub
parent 853a48a5af
commit 3414e361e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 14 additions and 0 deletions

View File

@ -3,6 +3,20 @@
#
if(WIN32)
# CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION is only set when
# Visual Studio generators are used, but we need it
# when we use Ninja as well
if(NOT DEFINED CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION)
if(DEFINED ENV{WindowsSDKVersion})
string(REPLACE "\\" "" WINDOWS_SDK_VERSION $ENV{WindowsSDKVersion})
set(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION ${WINDOWS_SDK_VERSION})
message(STATUS "Use ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION} Windows SDK version")
else()
message(FATAL_ERROR "WindowsSDKVersion environment variable is not set,\
can't find Windows SDK version. Try to use vcvarsall.bat script")
endif()
endif()
set(PROGRAMFILES_ENV "ProgramFiles\(X86\)")
# check that PROGRAMFILES_ENV is defined, because in case of cross-compilation for Windows