From 3414e361e893123ea2f74ff8a6420b2b2e3703ea Mon Sep 17 00:00:00 2001 From: Andrey Babushkin Date: Thu, 2 May 2024 16:50:48 +0100 Subject: [PATCH] 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. --- .../api_validator/api_validator.cmake | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cmake/developer_package/api_validator/api_validator.cmake b/cmake/developer_package/api_validator/api_validator.cmake index e62206bfaaa..0fd1f2c03a3 100644 --- a/cmake/developer_package/api_validator/api_validator.cmake +++ b/cmake/developer_package/api_validator/api_validator.cmake @@ -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