Files
mandy/runtime/cmake/vulkan_headers_version.cmake
Courtyard Games 48ac7764b2 runtime: stop the configure when Vulkan headers are too old for the Windows runtime
Any vulkan/vulkan.h used to be accepted, so headers that are too old (conda-forge's
vulkan-headers resolves to 1.3.231 next to llvm-tools) configured fine and then failed
deep in the build: d3d12_com.h(42) "'calibrated': unknown override specifier" and 100+
errors in d3d12_vulkan_device.cpp, or VkPhysicalDevicePipelineBinaryFeaturesKHR in
vk_harness.cpp.

runtime/cmake/vulkan_headers_version.cmake reads VK_HEADER_VERSION from the headers
Vulkan::Headers points at (FetchContent's $<BUILD_INTERFACE:...> unwrapped) and fails
with the found and needed versions and how to fix it. The minimum, 294, is measured by
building the whole Windows runtime against Khronos header tags: v1.3.294 and SDK
1.4.304.0 build all 555 targets, SDK 1.3.280.0 all but vk_harness, 1.3.231 stops in the
D3D12 layer. Only Windows-runtime configures check, so the portable Linux/macOS tool
builds keep accepting older distribution headers.

tests/test_cmake_vulkan_headers_version.py runs the module with cmake -P on stub
headers and checks that the FetchContent and CI pins meet the minimum.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 19:35:41 +07:00

46 lines
2.5 KiB
CMake

# Stops a configure whose Vulkan headers are older than the Windows runtime needs. Any vulkan/vulkan.h used to be
# accepted, so old headers (conda-forge's vulkan-headers resolves to 1.3.231 next to llvm-tools) configured fine and
# then failed deep in the build: d3d12_com.h(42) "'calibrated': unknown override specifier" (no
# PFN_vkGetCalibratedTimestampsKHR) and 100+ errors in d3d12_vulkan_device.cpp. The minimum is measured by building
# the whole Windows runtime against the Khronos Vulkan-Headers tags (docs/testing.md, "Known problems"): v1.3.294
# builds every target, SDK 1.3.280.0 every target but vk_harness (VK_KHR_pipeline_binary, new in v1.3.294), and
# 1.3.231 stops in the D3D12 layer. The first Vulkan SDK at or above it is 1.3.296.0.
# Kept in its own file so tests/test_cmake_vulkan_headers_version.py can run it with `cmake -P`.
set(LEONIDA_VULKAN_HEADERS_MIN 294)
# include_dirs: the include directories of Vulkan::Headers. Generator expressions such as $<BUILD_INTERFACE:...>
# (FetchContent's target) are unwrapped. A header with no VK_HEADER_VERSION line is left alone.
function(leonida_vulkan_headers_version include_dirs)
set(core "")
foreach(dir IN LISTS include_dirs)
string(REGEX REPLACE "^\\$<BUILD_INTERFACE:(.*)>$" "\\1" dir "${dir}")
if(dir MATCHES "^\\$<" OR NOT dir)
continue()
endif()
if(EXISTS "${dir}/vulkan/vulkan_core.h")
set(core "${dir}/vulkan/vulkan_core.h")
break()
endif()
endforeach()
if(NOT core)
return()
endif()
file(STRINGS "${core}" line REGEX "^#define VK_HEADER_VERSION [0-9]+" LIMIT_COUNT 1)
if(NOT line MATCHES "VK_HEADER_VERSION ([0-9]+)")
return()
endif()
set(found "${CMAKE_MATCH_1}")
set(LEONIDA_VULKAN_HEADER_VERSION "${found}" PARENT_SCOPE)
if(found LESS LEONIDA_VULKAN_HEADERS_MIN)
string(CONCAT text
"Vulkan headers too old: ${core} has VK_HEADER_VERSION ${found}, and the Windows runtime needs "
"${LEONIDA_VULKAN_HEADERS_MIN} or newer (Khronos Vulkan-Headers v1.3.${LEONIDA_VULKAN_HEADERS_MIN}, or a "
"Vulkan SDK from 1.3.296.0 on). The build would otherwise stop part way, for very old headers deep in the "
"D3D12 layer with errors such as \"'calibrated': unknown override specifier\". Point VULKAN_SDK (or "
"Vulkan_INCLUDE_DIR) at newer headers and delete CMakeCache.txt, which keeps the old lookup, or pass "
"-DLEONIDA_VULKAN_HEADERS_FETCH=ON with no other headers installed to download the pinned Khronos "
"Vulkan-Headers release.")
message(FATAL_ERROR "${text}")
endif()
endfunction()