Skip to content

Commit

Permalink
Updated detection of Windows SDK version in CMake 3.27
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMostDiligent committed Oct 20, 2023
1 parent 813864e commit c48e38e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,18 @@ endif()
message("CMake generator: " ${CMAKE_GENERATOR})

if(WIN32)
set(WINDOWS_SDK_VERSION ${CMAKE_SYSTEM_VERSION})
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.27" AND ${CMAKE_GENERATOR} MATCHES "Visual Studio")
# https://cmake.org/cmake/help/latest/policy/CMP0149.html
set(WINDOWS_SDK_VERSION ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION})
endif()

if(${CMAKE_SYSTEM_NAME} STREQUAL "WindowsStore")
set(PLATFORM_UNIVERSAL_WINDOWS TRUE CACHE INTERNAL "Target platform: Windows Store")
message("Target platform: Universal Windows " ${ARCH} ". SDK Version: " ${CMAKE_SYSTEM_VERSION})
message("Target platform: Universal Windows " ${ARCH} ". SDK Version: " ${WINDOWS_SDK_VERSION})
else()
set(PLATFORM_WIN32 TRUE CACHE INTERNAL "Target platform: Win32") #WIN32 is a variable, so we cannot use string "WIN32"
message("Target platform: Win32 " ${ARCH} ". SDK Version: " ${CMAKE_SYSTEM_VERSION})
message("Target platform: Win32 " ${ARCH} ". SDK Version: " ${WINDOWS_SDK_VERSION})
endif()
else()
if(${CMAKE_SYSTEM_NAME} STREQUAL "Android")
Expand Down Expand Up @@ -144,7 +150,7 @@ add_library(Diligent-PublicBuildSettings INTERFACE)
if(PLATFORM_WIN32)
if(MSVC)
set(D3D11_SUPPORTED TRUE CACHE INTERNAL "D3D11 is supported on Win32 platform")
if(CMAKE_SYSTEM_VERSION VERSION_GREATER_EQUAL "10.0")
if(WINDOWS_SDK_VERSION VERSION_GREATER_EQUAL "10.0")
set(D3D12_SUPPORTED TRUE CACHE INTERNAL "D3D12 is supported on Win32 platform")
endif()
else()
Expand All @@ -160,7 +166,7 @@ if(PLATFORM_WIN32)
target_compile_definitions(Diligent-PublicBuildSettings INTERFACE PLATFORM_WIN32=1)
elseif(PLATFORM_UNIVERSAL_WINDOWS)
set(D3D11_SUPPORTED TRUE CACHE INTERNAL "D3D11 is supported on Universal Windows platform")
if(CMAKE_SYSTEM_VERSION VERSION_GREATER_EQUAL "10.0")
if(WINDOWS_SDK_VERSION VERSION_GREATER_EQUAL "10.0")
set(D3D12_SUPPORTED TRUE CACHE INTERNAL "D3D12 is supported on Universal Windows platform")
endif()
set(ARCHIVER_SUPPORTED TRUE CACHE INTERNAL "Archiver is supported on Universal Windows platform")
Expand Down

0 comments on commit c48e38e

Please sign in to comment.