From 1a672f7bfff82b60ad61860b1feba93e0978917d Mon Sep 17 00:00:00 2001 From: "Giancane, Francesco" Date: Wed, 25 Feb 2026 15:10:28 +0000 Subject: [PATCH 01/11] Remove vendored downstream version of `FindVulkan.cmake` Let CMake use its own bundled version of this module. It is more maintained and has some quality of life fixed, most notably cross-compilation on Windows(ARM64/Intel). See #1489 for more context about this change. --- bldsys/cmake/module/FindVulkan.cmake | 962 --------------------------- 1 file changed, 962 deletions(-) delete mode 100644 bldsys/cmake/module/FindVulkan.cmake diff --git a/bldsys/cmake/module/FindVulkan.cmake b/bldsys/cmake/module/FindVulkan.cmake deleted file mode 100644 index 526301938d..0000000000 --- a/bldsys/cmake/module/FindVulkan.cmake +++ /dev/null @@ -1,962 +0,0 @@ -# Updates for iOS Copyright (c) 2024, Holochip Inc. -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#[=======================================================================[.rst: -FindVulkan ----------- - -.. versionadded:: 3.7 - -Find Vulkan, which is a low-overhead, cross-platform 3D graphics -and computing API. - -Optional COMPONENTS -^^^^^^^^^^^^^^^^^^^ - -.. versionadded:: 3.24 - -This module respects several optional COMPONENTS. -There are corresponding imported targets for each of these. - -``glslc`` - The SPIR-V compiler. - -``glslangValidator`` - The ``glslangValidator`` tool. - -``glslang`` - The SPIR-V generator library. - -``shaderc_combined`` - The static library for Vulkan shader compilation. - -``SPIRV-Tools`` - Tools to process SPIR-V modules. - -``MoltenVK`` - On macOS, an additional component ``MoltenVK`` is available. - -``dxc`` - .. versionadded:: 3.25 - - The DirectX Shader Compiler. - -The ``glslc`` and ``glslangValidator`` components are provided even -if not explicitly requested (for backward compatibility). - -IMPORTED Targets -^^^^^^^^^^^^^^^^ - -This module defines :prop_tgt:`IMPORTED` targets if Vulkan has been found: - -``Vulkan::Vulkan`` - The main Vulkan library. - -``Vulkan::glslc`` - .. versionadded:: 3.19 - - The GLSLC SPIR-V compiler, if it has been found. - -``Vulkan::Headers`` - .. versionadded:: 3.21 - - Provides just Vulkan headers include paths, if found. No library is - included in this target. This can be useful for applications that - load Vulkan library dynamically. - -``Vulkan::glslangValidator`` - .. versionadded:: 3.21 - - The glslangValidator tool, if found. It is used to compile GLSL and - HLSL shaders into SPIR-V. - -``Vulkan::glslang`` - .. versionadded:: 3.24 - - Defined if SDK has the Khronos-reference front-end shader parser and SPIR-V - generator library (glslang). - -``Vulkan::shaderc_combined`` - .. versionadded:: 3.24 - - Defined if SDK has the Google static library for Vulkan shader compilation - (shaderc_combined). - -``Vulkan::SPIRV-Tools`` - .. versionadded:: 3.24 - - Defined if SDK has the Khronos library to process SPIR-V modules - (SPIRV-Tools). - -``Vulkan::MoltenVK`` - .. versionadded:: 3.24 - - Defined if SDK has the Khronos library which implement a subset of Vulkan API - over Apple Metal graphics framework. (MoltenVK). - -``Vulkan::volk`` - .. versionadded:: 3.25 - - Defined if SDK has the Vulkan meta-loader (volk). - -``Vulkan::dxc_lib`` - .. versionadded:: 3.25 - - Defined if SDK has the DirectX shader compiler library. - -``Vulkan::dxc_exe`` - .. versionadded:: 3.25 - - Defined if SDK has the DirectX shader compiler CLI tool. - -Result Variables -^^^^^^^^^^^^^^^^ - -This module defines the following variables: - -``Vulkan_FOUND`` - set to true if Vulkan was found -``Vulkan_INCLUDE_DIRS`` - include directories for Vulkan -``Vulkan_LIBRARIES`` - link against this library to use Vulkan -``Vulkan_VERSION`` - .. versionadded:: 3.23 - - value from ``vulkan/vulkan_core.h`` -``Vulkan_glslc_FOUND`` - .. versionadded:: 3.24 - - True, if the SDK has the glslc executable. -``Vulkan_glslangValidator_FOUND`` - .. versionadded:: 3.24 - - True, if the SDK has the glslangValidator executable. -``Vulkan_glslang_FOUND`` - .. versionadded:: 3.24 - - True, if the SDK has the glslang library. -``Vulkan_shaderc_combined_FOUND`` - .. versionadded:: 3.24 - - True, if the SDK has the shaderc_combined library. -``Vulkan_SPIRV-Tools_FOUND`` - .. versionadded:: 3.24 - - True, if the SDK has the SPIRV-Tools library. -``Vulkan_MoltenVK_FOUND`` - .. versionadded:: 3.24 - - True, if the SDK has the MoltenVK library. -``Vulkan_volk_FOUND`` - .. versionadded:: 3.25 - - True, if the SDK has the volk library. - -``Vulkan_dxc_lib_FOUND`` - .. versionadded:: 3.25 - - True, if the SDK has the DirectX shader compiler library. - -``Vulkan_dxc_exe_FOUND`` - .. versionadded:: 3.25 - - True, if the SDK has the DirectX shader compiler CLI tool. - - -The module will also defines these cache variables: - -``Vulkan_INCLUDE_DIR`` - the Vulkan include directory -``Vulkan_LIBRARY`` - the path to the Vulkan library -``Vulkan_GLSLC_EXECUTABLE`` - the path to the GLSL SPIR-V compiler -``Vulkan_GLSLANG_VALIDATOR_EXECUTABLE`` - the path to the glslangValidator tool -``Vulkan_glslang_LIBRARY`` - .. versionadded:: 3.24 - - Path to the glslang library. -``Vulkan_shaderc_combined_LIBRARY`` - .. versionadded:: 3.24 - - Path to the shaderc_combined library. -``Vulkan_SPIRV-Tools_LIBRARY`` - .. versionadded:: 3.24 - - Path to the SPIRV-Tools library. -``Vulkan_MoltenVK_LIBRARY`` - .. versionadded:: 3.24 - - Path to the MoltenVK library. - -``Vulkan_volk_LIBRARY`` - .. versionadded:: 3.25 - - Path to the volk library. - -``Vulkan_dxc_LIBRARY`` - .. versionadded:: 3.25 - - Path to the DirectX shader compiler library. - -``Vulkan_dxc_EXECUTABLE`` - .. versionadded:: 3.25 - - Path to the DirectX shader compiler CLI tool. - -Hints -^^^^^ - -.. versionadded:: 3.18 - -The ``VULKAN_SDK`` environment variable optionally specifies the -location of the Vulkan SDK root directory for the given -architecture. It is typically set by sourcing the toplevel -``setup-env.sh`` script of the Vulkan SDK directory into the shell -environment. - -#]=======================================================================] - -cmake_policy(PUSH) -cmake_policy(SET CMP0057 NEW) - -# Provide compatibility with a common invalid component request that -# was silently ignored prior to CMake 3.24. -if("FATAL_ERROR" IN_LIST Vulkan_FIND_COMPONENTS) - message(AUTHOR_WARNING - "Ignoring unknown component 'FATAL_ERROR'.\n" - "The find_package() command documents no such argument." - ) - list(REMOVE_ITEM Vulkan_FIND_COMPONENTS "FATAL_ERROR") -endif() - -# FindVulkan only works correctly with the default CMAKE_FIND_FRAMEWORK -# value: FIRST. If LAST it will find the macOS dylibs instead of the iOS -# frameworks when IOS is true. If ALWAYS it will fail to find the macOS -# dylibs. If NEVER it will fail to find the iOS frameworks. If frameworks -# are ever included in the SDK for macOS, the search mechanism will need -# revisiting. -if(DEFINED CMAKE_FIND_FRAMEWORK) - set(_Vulkan_saved_cmake_find_framework ${CMAKE_FIND_FRAMEWORK}) - set(CMAKE_FIND_FRAMEWORK FIRST) -endif() - -if(IOS) - get_filename_component(Vulkan_Target_SDK "$ENV{VULKAN_SDK}/.." REALPATH) - list(APPEND CMAKE_FRAMEWORK_PATH "${Vulkan_Target_SDK}/iOS/lib") - set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) - set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) - set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) -endif() - -# For backward compatibility as `FindVulkan` in previous CMake versions allow to retrieve `glslc` -# and `glslangValidator` without requesting the corresponding component. -if(NOT glslc IN_LIST Vulkan_FIND_COMPONENTS) - list(APPEND Vulkan_FIND_COMPONENTS glslc) -endif() -if(NOT glslangValidator IN_LIST Vulkan_FIND_COMPONENTS) - list(APPEND Vulkan_FIND_COMPONENTS glslangValidator) -endif() - -if(WIN32) - set(_Vulkan_library_name vulkan-1) - set(_Vulkan_hint_include_search_paths - "$ENV{VULKAN_SDK}/include" - ) - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(_Vulkan_hint_executable_search_paths - "$ENV{VULKAN_SDK}/bin" - ) - set(_Vulkan_hint_library_search_paths - "$ENV{VULKAN_SDK}/lib" - "$ENV{VULKAN_SDK}/bin" - ) - else() - set(_Vulkan_hint_executable_search_paths - "$ENV{VULKAN_SDK}/bin32" - "$ENV{VULKAN_SDK}/bin" - ) - set(_Vulkan_hint_library_search_paths - "$ENV{VULKAN_SDK}/lib32" - "$ENV{VULKAN_SDK}/bin32" - "$ENV{VULKAN_SDK}/lib" - "$ENV{VULKAN_SDK}/bin" - ) - endif() -else() - set(_Vulkan_library_name vulkan) - set(_Vulkan_hint_include_search_paths - "$ENV{VULKAN_SDK}/include" - ) - set(_Vulkan_hint_executable_search_paths - "$ENV{VULKAN_SDK}/bin" - ) - set(_Vulkan_hint_library_search_paths - "$ENV{VULKAN_SDK}/lib" - ) -endif() -if(APPLE AND DEFINED Vulkan_Target_SDK) - list(APPEND _Vulkan_hint_include_search_paths - "${Vulkan_Target_SDK}/macOS/include" - ) - if(CMAKE_SYSTEM_NAME STREQUAL "iOS") - list(APPEND _Vulkan_hint_library_search_paths - "${Vulkan_Target_SDK}/iOS/lib" - ) - elseif(CMAKE_SYSTEM_NAME STREQUAL "tvOS") - list(APPEND _Vulkan_hint_library_search_paths - "${Vulkan_Target_SDK}/tvOS/lib" - ) - else() - list(APPEND _Vulkan_hint_library_search_paths - "${Vulkan_Target_SDK}/lib" - ) - endif() -endif() - -find_path(Vulkan_INCLUDE_DIR - NAMES vulkan/vulkan.h - HINTS - ${_Vulkan_hint_include_search_paths} -) -mark_as_advanced(Vulkan_INCLUDE_DIR) - -find_library(Vulkan_LIBRARY - NAMES ${_Vulkan_library_name} - HINTS - ${_Vulkan_hint_library_search_paths} -) -#message(STATUS "vulkan_library ${Vulkan_LIBRARY} search paths ${_Vulkan_hint_library_search_paths}") -mark_as_advanced(Vulkan_LIBRARY) - -find_library(Vulkan_Layer_API_DUMP - NAMES VkLayer_api_dump - HINTS - ${_Vulkan_hint_library_search_paths} -) -mark_as_advanced(Vulkan_Layer_API_DUMP) - -find_library(Vulkan_Layer_SHADER_OBJECT - NAMES VkLayer_khronos_shader_object - HINTS - ${_Vulkan_hint_library_search_paths} -) -mark_as_advanced(VkLayer_khronos_shader_object) - -find_library(Vulkan_Layer_SYNC2 - NAMES VkLayer_khronos_synchronization2 - HINTS - ${_Vulkan_hint_library_search_paths} -) -mark_as_advanced(Vulkan_Layer_SYNC2) - -find_library(Vulkan_Layer_VALIDATION - NAMES VkLayer_khronos_validation - HINTS - ${_Vulkan_hint_library_search_paths} -) -mark_as_advanced(Vulkan_Layer_VALIDATION) - -if(glslc IN_LIST Vulkan_FIND_COMPONENTS) - find_program(Vulkan_GLSLC_EXECUTABLE - NAMES glslc - HINTS - ${_Vulkan_hint_executable_search_paths} - ) - mark_as_advanced(Vulkan_GLSLC_EXECUTABLE) -endif() -if(glslangValidator IN_LIST Vulkan_FIND_COMPONENTS) - find_program(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE - NAMES glslangValidator - HINTS - ${_Vulkan_hint_executable_search_paths} - ) - mark_as_advanced(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE) -endif() -if(glslang IN_LIST Vulkan_FIND_COMPONENTS) - find_library(Vulkan_glslang-spirv_LIBRARY - NAMES SPIRV - HINTS - ${_Vulkan_hint_library_search_paths} - ) - mark_as_advanced(Vulkan_glslang-spirv_LIBRARY) - - find_library(Vulkan_glslang-spirv_DEBUG_LIBRARY - NAMES SPIRVd - HINTS - ${_Vulkan_hint_library_search_paths} - ) - mark_as_advanced(Vulkan_glslang-spirv_DEBUG_LIBRARY) - - find_library(Vulkan_glslang-oglcompiler_LIBRARY - NAMES OGLCompiler - HINTS - ${_Vulkan_hint_library_search_paths} - ) - mark_as_advanced(Vulkan_glslang-oglcompiler_LIBRARY) - - find_library(Vulkan_glslang-oglcompiler_DEBUG_LIBRARY - NAMES OGLCompilerd - HINTS - ${_Vulkan_hint_library_search_paths} - ) - mark_as_advanced(Vulkan_glslang-oglcompiler_DEBUG_LIBRARY) - - find_library(Vulkan_glslang-osdependent_LIBRARY - NAMES OSDependent - HINTS - ${_Vulkan_hint_library_search_paths} - ) - mark_as_advanced(Vulkan_glslang-osdependent_LIBRARY) - - find_library(Vulkan_glslang-osdependent_DEBUG_LIBRARY - NAMES OSDependentd - HINTS - ${_Vulkan_hint_library_search_paths} - ) - mark_as_advanced(Vulkan_glslang-osdependent_DEBUG_LIBRARY) - - find_library(Vulkan_glslang-machineindependent_LIBRARY - NAMES MachineIndependent - HINTS - ${_Vulkan_hint_library_search_paths} - ) - mark_as_advanced(Vulkan_glslang-machineindependent_LIBRARY) - - find_library(Vulkan_glslang-machineindependent_DEBUG_LIBRARY - NAMES MachineIndependentd - HINTS - ${_Vulkan_hint_library_search_paths} - ) - mark_as_advanced(Vulkan_glslang-machineindependent_DEBUG_LIBRARY) - - find_library(Vulkan_glslang-genericcodegen_LIBRARY - NAMES GenericCodeGen - HINTS - ${_Vulkan_hint_library_search_paths} - ) - mark_as_advanced(Vulkan_glslang-genericcodegen_LIBRARY) - - find_library(Vulkan_glslang-genericcodegen_DEBUG_LIBRARY - NAMES GenericCodeGend - HINTS - ${_Vulkan_hint_library_search_paths} - ) - mark_as_advanced(Vulkan_glslang-genericcodegen_DEBUG_LIBRARY) - - find_library(Vulkan_glslang_LIBRARY - NAMES glslang - HINTS - ${_Vulkan_hint_library_search_paths} - ) - mark_as_advanced(Vulkan_glslang_LIBRARY) - - find_library(Vulkan_glslang_DEBUG_LIBRARY - NAMES glslangd - HINTS - ${_Vulkan_hint_library_search_paths} - ) - mark_as_advanced(Vulkan_glslang_DEBUG_LIBRARY) -endif() -if(shaderc_combined IN_LIST Vulkan_FIND_COMPONENTS) - find_library(Vulkan_shaderc_combined_LIBRARY - NAMES shaderc_combined - HINTS - ${_Vulkan_hint_library_search_paths}) - mark_as_advanced(Vulkan_shaderc_combined_LIBRARY) - - find_library(Vulkan_shaderc_combined_DEBUG_LIBRARY - NAMES shaderc_combinedd - HINTS - ${_Vulkan_hint_library_search_paths}) - mark_as_advanced(Vulkan_shaderc_combined_DEBUG_LIBRARY) -endif() -if(SPIRV-Tools IN_LIST Vulkan_FIND_COMPONENTS) - find_library(Vulkan_SPIRV-Tools_LIBRARY - NAMES SPIRV-Tools - HINTS - ${_Vulkan_hint_library_search_paths}) - mark_as_advanced(Vulkan_SPIRV-Tools_LIBRARY) - - find_library(Vulkan_SPIRV-Tools_DEBUG_LIBRARY - NAMES SPIRV-Toolsd - HINTS - ${_Vulkan_hint_library_search_paths}) - mark_as_advanced(Vulkan_SPIRV-Tools_DEBUG_LIBRARY) -endif() -if(MoltenVK IN_LIST Vulkan_FIND_COMPONENTS) - # CMake has a bug in 3.28 that doesn't handle xcframeworks. Do it by hand for now. - if(CMAKE_SYSTEM_NAME STREQUAL "iOS") - if(CMAKE_VERSION VERSION_LESS 3.29) - set( _Vulkan_hint_library_search_paths ${Vulkan_Target_SDK}/ios/lib/MoltenVK.xcframework/ios-arm64) - else () - set( _Vulkan_hint_library_search_paths ${Vulkan_Target_SDK}/ios/lib/) - endif () - endif () - find_library(Vulkan_MoltenVK_LIBRARY - NAMES MoltenVK - NO_DEFAULT_PATH - HINTS - ${_Vulkan_hint_library_search_paths} - ) - mark_as_advanced(Vulkan_MoltenVK_LIBRARY) - - find_path(Vulkan_MoltenVK_INCLUDE_DIR - NAMES MoltenVK/mvk_vulkan.h - HINTS - ${_Vulkan_hint_include_search_paths} - ) - mark_as_advanced(Vulkan_MoltenVK_INCLUDE_DIR) -endif() -if(volk IN_LIST Vulkan_FIND_COMPONENTS) - find_library(Vulkan_volk_LIBRARY - NAMES volk - HINTS - ${_Vulkan_hint_library_search_paths}) - mark_as_advanced(Vulkan_Volk_LIBRARY) -endif() - -if (dxc IN_LIST Vulkan_FIND_COMPONENTS) - find_library(Vulkan_dxc_LIBRARY - NAMES dxcompiler - HINTS - ${_Vulkan_hint_library_search_paths}) - mark_as_advanced(Vulkan_dxc_LIBRARY) - - find_program(Vulkan_dxc_EXECUTABLE - NAMES dxc - HINTS - ${_Vulkan_hint_executable_search_paths}) - mark_as_advanced(Vulkan_dxc_EXECUTABLE) -endif() - -if(DEFINED _Vulkan_saved_cmake_find_framework) - set(CMAKE_FIND_FRAMEWORK ${_Vulkan_saved_cmake_find_framework}) - unset(_Vulkan_saved_cmake_find_framework) -endif() - -if(Vulkan_GLSLC_EXECUTABLE) - set(Vulkan_glslc_FOUND TRUE) -else() - set(Vulkan_glslc_FOUND FALSE) -endif() - -if(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE) - set(Vulkan_glslangValidator_FOUND TRUE) -else() - set(Vulkan_glslangValidator_FOUND FALSE) -endif() - -if (Vulkan_dxc_EXECUTABLE) - set(Vulkan_dxc_exe_FOUND TRUE) -else() - set(Vulkan_dxc_exe_FOUND FALSE) -endif() - -function(_Vulkan_set_library_component_found component) - cmake_parse_arguments(PARSE_ARGV 1 _ARG - "NO_WARNING" - "" - "DEPENDENT_COMPONENTS") - - set(all_dependent_component_found TRUE) - foreach(dependent_component IN LISTS _ARG_DEPENDENT_COMPONENTS) - if(NOT Vulkan_${dependent_component}_FOUND) - set(all_dependent_component_found FALSE) - break() - endif() - endforeach() - - if(all_dependent_component_found AND (Vulkan_${component}_LIBRARY OR Vulkan_${component}_DEBUG_LIBRARY)) - set(Vulkan_${component}_FOUND TRUE PARENT_SCOPE) - - # For Windows Vulkan SDK, third party tools binaries are provided with different MSVC ABI: - # - Release binaries uses a runtime library - # - Debug binaries uses a debug runtime library - # This lead to incompatibilities in linking for some configuration types due to CMake-default or project-configured selected MSVC ABI. - if(WIN32 AND NOT _ARG_NO_WARNING) - if(NOT Vulkan_${component}_LIBRARY) - message(WARNING - "Library ${component} for Release configuration is missing, imported target Vulkan::${component} may not be able to link when targeting this build configuration due to incompatible MSVC ABI.") - endif() - if(NOT Vulkan_${component}_DEBUG_LIBRARY) - message(WARNING - "Library ${component} for Debug configuration is missing, imported target Vulkan::${component} may not be able to link when targeting this build configuration due to incompatible MSVC ABI. Consider re-installing the Vulkan SDK and request debug libraries to fix this warning.") - endif() - endif() - else() - set(Vulkan_${component}_FOUND FALSE PARENT_SCOPE) - endif() -endfunction() - -_Vulkan_set_library_component_found(glslang-spirv NO_WARNING) -_Vulkan_set_library_component_found(glslang-oglcompiler NO_WARNING) -_Vulkan_set_library_component_found(glslang-osdependent NO_WARNING) -_Vulkan_set_library_component_found(glslang-machineindependent NO_WARNING) -_Vulkan_set_library_component_found(glslang-genericcodegen NO_WARNING) -_Vulkan_set_library_component_found(glslang - DEPENDENT_COMPONENTS - glslang-spirv - glslang-oglcompiler - glslang-osdependent - glslang-machineindependent - glslang-genericcodegen) -_Vulkan_set_library_component_found(shaderc_combined) -_Vulkan_set_library_component_found(SPIRV-Tools) -_Vulkan_set_library_component_found(volk) -_Vulkan_set_library_component_found(dxc) - -if(Vulkan_MoltenVK_INCLUDE_DIR AND Vulkan_MoltenVK_LIBRARY) - set(Vulkan_MoltenVK_FOUND TRUE) -else() - set(Vulkan_MoltenVK_FOUND FALSE) -endif() - -set(Vulkan_LIBRARIES ${Vulkan_LIBRARY}) -set(Vulkan_INCLUDE_DIRS ${Vulkan_INCLUDE_DIR}) - -# detect version e.g 1.2.189 -set(Vulkan_VERSION "") -if(Vulkan_INCLUDE_DIR) - set(VULKAN_CORE_H ${Vulkan_INCLUDE_DIR}/vulkan/vulkan_core.h) - if(EXISTS ${VULKAN_CORE_H}) - file(STRINGS ${VULKAN_CORE_H} VulkanHeaderVersionLine REGEX "^#define VK_HEADER_VERSION ") - string(REGEX MATCHALL "[0-9]+" VulkanHeaderVersion "${VulkanHeaderVersionLine}") - file(STRINGS ${VULKAN_CORE_H} VulkanHeaderVersionLine2 REGEX "^#define VK_HEADER_VERSION_COMPLETE ") - string(REGEX MATCHALL "[0-9]+" VulkanHeaderVersion2 "${VulkanHeaderVersionLine2}") - list(LENGTH VulkanHeaderVersion2 _len) - # versions >= 1.2.175 have an additional numbers in front of e.g. '0, 1, 2' instead of '1, 2' - if(_len EQUAL 3) - list(REMOVE_AT VulkanHeaderVersion2 0) - endif() - list(APPEND VulkanHeaderVersion2 ${VulkanHeaderVersion}) - list(JOIN VulkanHeaderVersion2 "." Vulkan_VERSION) - endif() -endif() - -if(Vulkan_MoltenVK_FOUND) - set(Vulkan_MoltenVK_VERSION "") - if(Vulkan_MoltenVK_INCLUDE_DIR) - set(VK_MVK_MOLTENVK_H ${Vulkan_MoltenVK_INCLUDE_DIR}/MoltenVK/vk_mvk_moltenvk.h) - if(EXISTS ${VK_MVK_MOLTENVK_H}) - file(STRINGS ${VK_MVK_MOLTENVK_H} _Vulkan_MoltenVK_VERSION_MAJOR REGEX "^#define MVK_VERSION_MAJOR ") - string(REGEX MATCHALL "[0-9]+" _Vulkan_MoltenVK_VERSION_MAJOR "${_Vulkan_MoltenVK_VERSION_MAJOR}") - file(STRINGS ${VK_MVK_MOLTENVK_H} _Vulkan_MoltenVK_VERSION_MINOR REGEX "^#define MVK_VERSION_MINOR ") - string(REGEX MATCHALL "[0-9]+" _Vulkan_MoltenVK_VERSION_MINOR "${_Vulkan_MoltenVK_VERSION_MINOR}") - file(STRINGS ${VK_MVK_MOLTENVK_H} _Vulkan_MoltenVK_VERSION_PATCH REGEX "^#define MVK_VERSION_PATCH ") - string(REGEX MATCHALL "[0-9]+" _Vulkan_MoltenVK_VERSION_PATCH "${_Vulkan_MoltenVK_VERSION_PATCH}") - set(Vulkan_MoltenVK_VERSION "${_Vulkan_MoltenVK_VERSION_MAJOR}.${_Vulkan_MoltenVK_VERSION_MINOR}.${_Vulkan_MoltenVK_VERSION_PATCH}") - unset(_Vulkan_MoltenVK_VERSION_MAJOR) - unset(_Vulkan_MoltenVK_VERSION_MINOR) - unset(_Vulkan_MoltenVK_VERSION_PATCH) - endif() - endif() -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(Vulkan - REQUIRED_VARS - Vulkan_LIBRARY - Vulkan_INCLUDE_DIR - VERSION_VAR - Vulkan_VERSION - HANDLE_COMPONENTS -) - -if(Vulkan_FOUND AND NOT TARGET Vulkan::Vulkan) - add_library(Vulkan::Vulkan UNKNOWN IMPORTED) - get_filename_component(_Vulkan_lib_extension ${Vulkan_LIBRARIES} LAST_EXT) - if(_Vulkan_lib_extension STREQUAL ".framework" AND CMAKE_VERSION VERSION_LESS 3.28) - set_target_properties(Vulkan::Vulkan PROPERTIES - # Prior to 3.28 must reference library just inside the framework. - IMPORTED_LOCATION "${Vulkan_LIBRARIES}/vulkan") - else() - set_target_properties(Vulkan::Vulkan PROPERTIES - IMPORTED_LOCATION "${Vulkan_LIBRARIES}") - endif() - set_target_properties(Vulkan::Vulkan PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") - unset(_Vulkan_lib_extension) -endif() - -if(Vulkan_FOUND AND NOT TARGET Vulkan::Headers) - add_library(Vulkan::Headers INTERFACE IMPORTED) - set_target_properties(Vulkan::Headers PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") -endif() - -if(Vulkan_FOUND AND Vulkan_GLSLC_EXECUTABLE AND NOT TARGET Vulkan::glslc) - add_executable(Vulkan::glslc IMPORTED) - set_property(TARGET Vulkan::glslc PROPERTY IMPORTED_LOCATION "${Vulkan_GLSLC_EXECUTABLE}") -endif() - -if(Vulkan_FOUND AND Vulkan_GLSLANG_VALIDATOR_EXECUTABLE AND NOT TARGET Vulkan::glslangValidator) - add_executable(Vulkan::glslangValidator IMPORTED) - set_property(TARGET Vulkan::glslangValidator PROPERTY IMPORTED_LOCATION "${Vulkan_GLSLANG_VALIDATOR_EXECUTABLE}") -endif() - -if(Vulkan_FOUND) - if((Vulkan_glslang-spirv_LIBRARY OR Vulkan_glslang-spirv_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-spirv) - add_library(Vulkan::glslang-spirv STATIC IMPORTED) - set_property(TARGET Vulkan::glslang-spirv - PROPERTY - INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") - if(Vulkan_glslang-spirv_LIBRARY) - set_property(TARGET Vulkan::glslang-spirv APPEND - PROPERTY - IMPORTED_CONFIGURATIONS Release) - set_property(TARGET Vulkan::glslang-spirv - PROPERTY - IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-spirv_LIBRARY}") - endif() - if(Vulkan_glslang-spirv_DEBUG_LIBRARY) - set_property(TARGET Vulkan::glslang-spirv APPEND - PROPERTY - IMPORTED_CONFIGURATIONS Debug) - set_property(TARGET Vulkan::glslang-spirv - PROPERTY - IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-spirv_DEBUG_LIBRARY}") - endif() - endif() - - if((Vulkan_glslang-oglcompiler_LIBRARY OR Vulkan_glslang-oglcompiler_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-oglcompiler) - add_library(Vulkan::glslang-oglcompiler STATIC IMPORTED) - set_property(TARGET Vulkan::glslang-oglcompiler - PROPERTY - INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") - if(Vulkan_glslang-oglcompiler_LIBRARY) - set_property(TARGET Vulkan::glslang-oglcompiler APPEND - PROPERTY - IMPORTED_CONFIGURATIONS Release) - set_property(TARGET Vulkan::glslang-oglcompiler - PROPERTY - IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-oglcompiler_LIBRARY}") - endif() - if(Vulkan_glslang-oglcompiler_DEBUG_LIBRARY) - set_property(TARGET Vulkan::glslang-oglcompiler APPEND - PROPERTY - IMPORTED_CONFIGURATIONS Debug) - set_property(TARGET Vulkan::glslang-oglcompiler - PROPERTY - IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-oglcompiler_DEBUG_LIBRARY}") - endif() - endif() - - if((Vulkan_glslang-osdependent_LIBRARY OR Vulkan_glslang-osdependent_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-osdependent) - add_library(Vulkan::glslang-osdependent STATIC IMPORTED) - set_property(TARGET Vulkan::glslang-osdependent - PROPERTY - INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") - if(Vulkan_glslang-osdependent_LIBRARY) - set_property(TARGET Vulkan::glslang-osdependent APPEND - PROPERTY - IMPORTED_CONFIGURATIONS Release) - set_property(TARGET Vulkan::glslang-osdependent - PROPERTY - IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-osdependent_LIBRARY}") - endif() - if(Vulkan_glslang-osdependent_DEBUG_LIBRARY) - set_property(TARGET Vulkan::glslang-osdependent APPEND - PROPERTY - IMPORTED_CONFIGURATIONS Debug) - set_property(TARGET Vulkan::glslang-osdependent - PROPERTY - IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-osdependent_DEBUG_LIBRARY}") - endif() - endif() - - if((Vulkan_glslang-machineindependent_LIBRARY OR Vulkan_glslang-machineindependent_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-machineindependent) - add_library(Vulkan::glslang-machineindependent STATIC IMPORTED) - set_property(TARGET Vulkan::glslang-machineindependent - PROPERTY - INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") - if(Vulkan_glslang-machineindependent_LIBRARY) - set_property(TARGET Vulkan::glslang-machineindependent APPEND - PROPERTY - IMPORTED_CONFIGURATIONS Release) - set_property(TARGET Vulkan::glslang-machineindependent - PROPERTY - IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-machineindependent_LIBRARY}") - endif() - if(Vulkan_glslang-machineindependent_DEBUG_LIBRARY) - set_property(TARGET Vulkan::glslang-machineindependent APPEND - PROPERTY - IMPORTED_CONFIGURATIONS Debug) - set_property(TARGET Vulkan::glslang-machineindependent - PROPERTY - IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-machineindependent_DEBUG_LIBRARY}") - endif() - endif() - - if((Vulkan_glslang-genericcodegen_LIBRARY OR Vulkan_glslang-genericcodegen_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-genericcodegen) - add_library(Vulkan::glslang-genericcodegen STATIC IMPORTED) - set_property(TARGET Vulkan::glslang-genericcodegen - PROPERTY - INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") - if(Vulkan_glslang-genericcodegen_LIBRARY) - set_property(TARGET Vulkan::glslang-genericcodegen APPEND - PROPERTY - IMPORTED_CONFIGURATIONS Release) - set_property(TARGET Vulkan::glslang-genericcodegen - PROPERTY - IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-genericcodegen_LIBRARY}") - endif() - if(Vulkan_glslang-genericcodegen_DEBUG_LIBRARY) - set_property(TARGET Vulkan::glslang-genericcodegen APPEND - PROPERTY - IMPORTED_CONFIGURATIONS Debug) - set_property(TARGET Vulkan::glslang-genericcodegen - PROPERTY - IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-genericcodegen_DEBUG_LIBRARY}") - endif() - endif() - - if((Vulkan_glslang_LIBRARY OR Vulkan_glslang_DEBUG_LIBRARY) - AND TARGET Vulkan::glslang-spirv - AND TARGET Vulkan::glslang-oglcompiler - AND TARGET Vulkan::glslang-osdependent - AND TARGET Vulkan::glslang-machineindependent - AND TARGET Vulkan::glslang-genericcodegen - AND NOT TARGET Vulkan::glslang) - add_library(Vulkan::glslang STATIC IMPORTED) - set_property(TARGET Vulkan::glslang - PROPERTY - INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") - if(Vulkan_glslang_LIBRARY) - set_property(TARGET Vulkan::glslang APPEND - PROPERTY - IMPORTED_CONFIGURATIONS Release) - set_property(TARGET Vulkan::glslang - PROPERTY - IMPORTED_LOCATION_RELEASE "${Vulkan_glslang_LIBRARY}") - endif() - if(Vulkan_glslang_DEBUG_LIBRARY) - set_property(TARGET Vulkan::glslang APPEND - PROPERTY - IMPORTED_CONFIGURATIONS Debug) - set_property(TARGET Vulkan::glslang - PROPERTY - IMPORTED_LOCATION_DEBUG "${Vulkan_glslang_DEBUG_LIBRARY}") - endif() - target_link_libraries(Vulkan::glslang - INTERFACE - Vulkan::glslang-spirv - Vulkan::glslang-oglcompiler - Vulkan::glslang-osdependent - Vulkan::glslang-machineindependent - Vulkan::glslang-genericcodegen - ) - endif() - - if((Vulkan_shaderc_combined_LIBRARY OR Vulkan_shaderc_combined_DEBUG_LIBRARY) AND NOT TARGET Vulkan::shaderc_combined) - add_library(Vulkan::shaderc_combined STATIC IMPORTED) - set_property(TARGET Vulkan::shaderc_combined - PROPERTY - INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") - if(Vulkan_shaderc_combined_LIBRARY) - set_property(TARGET Vulkan::shaderc_combined APPEND - PROPERTY - IMPORTED_CONFIGURATIONS Release) - set_property(TARGET Vulkan::shaderc_combined - PROPERTY - IMPORTED_LOCATION_RELEASE "${Vulkan_shaderc_combined_LIBRARY}") - endif() - if(Vulkan_shaderc_combined_DEBUG_LIBRARY) - set_property(TARGET Vulkan::shaderc_combined APPEND - PROPERTY - IMPORTED_CONFIGURATIONS Debug) - set_property(TARGET Vulkan::shaderc_combined - PROPERTY - IMPORTED_LOCATION_DEBUG "${Vulkan_shaderc_combined_DEBUG_LIBRARY}") - endif() - - if(UNIX) - find_package(Threads REQUIRED) - target_link_libraries(Vulkan::shaderc_combined - INTERFACE - Threads::Threads) - endif() - endif() - - if((Vulkan_SPIRV-Tools_LIBRARY OR Vulkan_SPIRV-Tools_DEBUG_LIBRARY) AND NOT TARGET Vulkan::SPIRV-Tools) - add_library(Vulkan::SPIRV-Tools STATIC IMPORTED) - set_property(TARGET Vulkan::SPIRV-Tools - PROPERTY - INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") - if(Vulkan_SPIRV-Tools_LIBRARY) - set_property(TARGET Vulkan::SPIRV-Tools APPEND - PROPERTY - IMPORTED_CONFIGURATIONS Release) - set_property(TARGET Vulkan::SPIRV-Tools - PROPERTY - IMPORTED_LOCATION_RELEASE "${Vulkan_SPIRV-Tools_LIBRARY}") - endif() - if(Vulkan_SPIRV-Tools_DEBUG_LIBRARY) - set_property(TARGET Vulkan::SPIRV-Tools APPEND - PROPERTY - IMPORTED_CONFIGURATIONS Debug) - set_property(TARGET Vulkan::SPIRV-Tools - PROPERTY - IMPORTED_LOCATION_DEBUG "${Vulkan_SPIRV-Tools_DEBUG_LIBRARY}") - endif() - endif() - - if(Vulkan_volk_LIBRARY AND NOT TARGET Vulkan::volk) - add_library(Vulkan::volk STATIC IMPORTED) - set_property(TARGET Vulkan::volk - PROPERTY - INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") - set_property(TARGET Vulkan::volk APPEND - PROPERTY - IMPORTED_CONFIGURATIONS Release) - set_property(TARGET Vulkan::volk APPEND - PROPERTY - IMPORTED_LOCATION_RELEASE "${Vulkan_volk_LIBRARY}") - - if (NOT WIN32) - set_property(TARGET Vulkan::volk APPEND - PROPERTY - IMPORTED_LINK_INTERFACE_LIBRARIES dl) - endif() - endif() - - if (Vulkan_dxc_LIBRARY AND NOT TARGET Vulkan::dxc_lib) - add_library(Vulkan::dxc_lib STATIC IMPORTED) - set_property(TARGET Vulkan::dxc_lib - PROPERTY - INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") - set_property(TARGET Vulkan::dxc_lib APPEND - PROPERTY - IMPORTED_CONFIGURATIONS Release) - set_property(TARGET Vulkan::dxc_lib APPEND - PROPERTY - IMPORTED_LOCATION_RELEASE "${Vulkan_dxc_LIBRARY}") - endif() - - if(Vulkan_dxc_EXECUTABLE AND NOT TARGET Vulkan::dxc_exe) - add_executable(Vulkan::dxc_exe IMPORTED) - set_property(TARGET Vulkan::dxc_exe PROPERTY IMPORTED_LOCATION "${Vulkan_dxc_EXECUTABLE}") - endif() - -endif() - -if(Vulkan_MoltenVK_FOUND) - if(Vulkan_MoltenVK_LIBRARY AND NOT TARGET Vulkan::MoltenVK) - add_library(Vulkan::MoltenVK SHARED IMPORTED) - set_target_properties(Vulkan::MoltenVK - PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_MoltenVK_INCLUDE_DIR}" - IMPORTED_LOCATION "${Vulkan_MoltenVK_LIBRARY}" - ) - endif() -endif() - -unset(_Vulkan_library_name) -unset(_Vulkan_hint_include_search_paths) -unset(_Vulkan_hint_executable_search_paths) -unset(_Vulkan_hint_library_search_paths) - -cmake_policy(POP) From 6f1680fda533017a62e8ea071cf8a14c18c2b9f1 Mon Sep 17 00:00:00 2001 From: "Giancane, Francesco" Date: Wed, 4 Mar 2026 18:14:16 +0000 Subject: [PATCH 02/11] bldsys/toolchain: introduce `ios.cmake` toolchain file As per upstream CMake recommendations, configure iOS targets using a toolchain file. --- bldsys/toolchain/ios.cmake | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 bldsys/toolchain/ios.cmake diff --git a/bldsys/toolchain/ios.cmake b/bldsys/toolchain/ios.cmake new file mode 100644 index 0000000000..28d4a9d23e --- /dev/null +++ b/bldsys/toolchain/ios.cmake @@ -0,0 +1,12 @@ +# As per upstream CMake recommendation in https://gitlab.kitware.com/cmake/cmake/-/issues/27661 +# to properly build for iOS we need a toolchain file. +# Toolchain file shall define: +# - Target system name to iOS +# - Export the $ENV{VULKAN_SDK} variable to `CMAKE_FIND_ROOT_PATH` +# iOS/setup-env.sh will take care of setting proper environment. + +set(CMAKE_SYSTEM_NAME iOS) +set(CMAKE_OSX_SYSROOT iphoneos) +set(CMAKE_OSX_DEPLOYMENT_TARGET 16.3) +set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED NO) +list(APPEND CMAKE_FIND_ROOT_PATH "$ENV{VULKAN_SDK}") From 265d31356e127a5c071034f325b79137cbee71ff Mon Sep 17 00:00:00 2001 From: "Giancane, Francesco" Date: Wed, 4 Mar 2026 18:20:33 +0000 Subject: [PATCH 03/11] build.yml: update workflow for iOS CI to use ios toolchain file Move all the variables that were passed through command line here, as per CMake upstream recommendation. --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5a78261d1d..0a1cd20986 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -194,5 +194,5 @@ jobs: - name: build_ios run: | source ~/VulkanSDK/iOS/setup-env.sh - cmake -H"." -B"build/ios" -DVKB_BUILD_TESTS=ON -DVKB_BUILD_SAMPLES=ON -G Xcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_DEPLOYMENT_TARGET=16.3 -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED=NO + cmake -H"." -B"build/ios" -DVKB_BUILD_TESTS=ON -DVKB_BUILD_SAMPLES=ON -G Xcode --toolchain bldsys/toolchain/ios.cmake cmake --build "build/ios" --target vulkan_samples --config ${{ matrix.build_type }} -- -allowProvisioningUpdates From fade4d591ebdb78cf71403d043c219219cf92be8 Mon Sep 17 00:00:00 2001 From: "Giancane, Francesco" Date: Thu, 5 Mar 2026 12:15:07 +0000 Subject: [PATCH 04/11] app/CMakeLists.txt: compute `Vulkan_Target_SDK` Removing downstream vendored version of `FindVulkan.cmake` caused this variable to disappear. Compute it again where it is needed. https://github.com/KhronosGroup/Vulkan-Samples/pull/1490#issuecomment-4001778127 for the full discussion. --- app/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 22c817f0ce..8dc3ebea43 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -137,6 +137,7 @@ if(IOS) endif () # Vulkan cache variables already defined by main project CMakeLists and updated on Apple platforms by global_options.cmake if(Vulkan_LIBRARY AND ${Vulkan_VERSION} VERSION_GREATER_EQUAL 1.3.278) + get_filename_component(Vulkan_Target_SDK "$ENV{VULKAN_SDK}/.." REALPATH) target_sources(${PROJECT_NAME} PRIVATE ${Vulkan_Target_SDK}/iOS/share/vulkan ) From 1e7d48cb9d827886dcc7807ba1dcd7a7b8c19a54 Mon Sep 17 00:00:00 2001 From: "Giancane, Francesco" Date: Fri, 6 Mar 2026 12:07:09 +0000 Subject: [PATCH 05/11] Revert "Remove vendored downstream version of `FindVulkan.cmake`" This reverts commit 1a672f7bfff82b60ad61860b1feba93e0978917d. --- bldsys/cmake/module/FindVulkan.cmake | 962 +++++++++++++++++++++++++++ 1 file changed, 962 insertions(+) create mode 100644 bldsys/cmake/module/FindVulkan.cmake diff --git a/bldsys/cmake/module/FindVulkan.cmake b/bldsys/cmake/module/FindVulkan.cmake new file mode 100644 index 0000000000..526301938d --- /dev/null +++ b/bldsys/cmake/module/FindVulkan.cmake @@ -0,0 +1,962 @@ +# Updates for iOS Copyright (c) 2024, Holochip Inc. +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +FindVulkan +---------- + +.. versionadded:: 3.7 + +Find Vulkan, which is a low-overhead, cross-platform 3D graphics +and computing API. + +Optional COMPONENTS +^^^^^^^^^^^^^^^^^^^ + +.. versionadded:: 3.24 + +This module respects several optional COMPONENTS. +There are corresponding imported targets for each of these. + +``glslc`` + The SPIR-V compiler. + +``glslangValidator`` + The ``glslangValidator`` tool. + +``glslang`` + The SPIR-V generator library. + +``shaderc_combined`` + The static library for Vulkan shader compilation. + +``SPIRV-Tools`` + Tools to process SPIR-V modules. + +``MoltenVK`` + On macOS, an additional component ``MoltenVK`` is available. + +``dxc`` + .. versionadded:: 3.25 + + The DirectX Shader Compiler. + +The ``glslc`` and ``glslangValidator`` components are provided even +if not explicitly requested (for backward compatibility). + +IMPORTED Targets +^^^^^^^^^^^^^^^^ + +This module defines :prop_tgt:`IMPORTED` targets if Vulkan has been found: + +``Vulkan::Vulkan`` + The main Vulkan library. + +``Vulkan::glslc`` + .. versionadded:: 3.19 + + The GLSLC SPIR-V compiler, if it has been found. + +``Vulkan::Headers`` + .. versionadded:: 3.21 + + Provides just Vulkan headers include paths, if found. No library is + included in this target. This can be useful for applications that + load Vulkan library dynamically. + +``Vulkan::glslangValidator`` + .. versionadded:: 3.21 + + The glslangValidator tool, if found. It is used to compile GLSL and + HLSL shaders into SPIR-V. + +``Vulkan::glslang`` + .. versionadded:: 3.24 + + Defined if SDK has the Khronos-reference front-end shader parser and SPIR-V + generator library (glslang). + +``Vulkan::shaderc_combined`` + .. versionadded:: 3.24 + + Defined if SDK has the Google static library for Vulkan shader compilation + (shaderc_combined). + +``Vulkan::SPIRV-Tools`` + .. versionadded:: 3.24 + + Defined if SDK has the Khronos library to process SPIR-V modules + (SPIRV-Tools). + +``Vulkan::MoltenVK`` + .. versionadded:: 3.24 + + Defined if SDK has the Khronos library which implement a subset of Vulkan API + over Apple Metal graphics framework. (MoltenVK). + +``Vulkan::volk`` + .. versionadded:: 3.25 + + Defined if SDK has the Vulkan meta-loader (volk). + +``Vulkan::dxc_lib`` + .. versionadded:: 3.25 + + Defined if SDK has the DirectX shader compiler library. + +``Vulkan::dxc_exe`` + .. versionadded:: 3.25 + + Defined if SDK has the DirectX shader compiler CLI tool. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module defines the following variables: + +``Vulkan_FOUND`` + set to true if Vulkan was found +``Vulkan_INCLUDE_DIRS`` + include directories for Vulkan +``Vulkan_LIBRARIES`` + link against this library to use Vulkan +``Vulkan_VERSION`` + .. versionadded:: 3.23 + + value from ``vulkan/vulkan_core.h`` +``Vulkan_glslc_FOUND`` + .. versionadded:: 3.24 + + True, if the SDK has the glslc executable. +``Vulkan_glslangValidator_FOUND`` + .. versionadded:: 3.24 + + True, if the SDK has the glslangValidator executable. +``Vulkan_glslang_FOUND`` + .. versionadded:: 3.24 + + True, if the SDK has the glslang library. +``Vulkan_shaderc_combined_FOUND`` + .. versionadded:: 3.24 + + True, if the SDK has the shaderc_combined library. +``Vulkan_SPIRV-Tools_FOUND`` + .. versionadded:: 3.24 + + True, if the SDK has the SPIRV-Tools library. +``Vulkan_MoltenVK_FOUND`` + .. versionadded:: 3.24 + + True, if the SDK has the MoltenVK library. +``Vulkan_volk_FOUND`` + .. versionadded:: 3.25 + + True, if the SDK has the volk library. + +``Vulkan_dxc_lib_FOUND`` + .. versionadded:: 3.25 + + True, if the SDK has the DirectX shader compiler library. + +``Vulkan_dxc_exe_FOUND`` + .. versionadded:: 3.25 + + True, if the SDK has the DirectX shader compiler CLI tool. + + +The module will also defines these cache variables: + +``Vulkan_INCLUDE_DIR`` + the Vulkan include directory +``Vulkan_LIBRARY`` + the path to the Vulkan library +``Vulkan_GLSLC_EXECUTABLE`` + the path to the GLSL SPIR-V compiler +``Vulkan_GLSLANG_VALIDATOR_EXECUTABLE`` + the path to the glslangValidator tool +``Vulkan_glslang_LIBRARY`` + .. versionadded:: 3.24 + + Path to the glslang library. +``Vulkan_shaderc_combined_LIBRARY`` + .. versionadded:: 3.24 + + Path to the shaderc_combined library. +``Vulkan_SPIRV-Tools_LIBRARY`` + .. versionadded:: 3.24 + + Path to the SPIRV-Tools library. +``Vulkan_MoltenVK_LIBRARY`` + .. versionadded:: 3.24 + + Path to the MoltenVK library. + +``Vulkan_volk_LIBRARY`` + .. versionadded:: 3.25 + + Path to the volk library. + +``Vulkan_dxc_LIBRARY`` + .. versionadded:: 3.25 + + Path to the DirectX shader compiler library. + +``Vulkan_dxc_EXECUTABLE`` + .. versionadded:: 3.25 + + Path to the DirectX shader compiler CLI tool. + +Hints +^^^^^ + +.. versionadded:: 3.18 + +The ``VULKAN_SDK`` environment variable optionally specifies the +location of the Vulkan SDK root directory for the given +architecture. It is typically set by sourcing the toplevel +``setup-env.sh`` script of the Vulkan SDK directory into the shell +environment. + +#]=======================================================================] + +cmake_policy(PUSH) +cmake_policy(SET CMP0057 NEW) + +# Provide compatibility with a common invalid component request that +# was silently ignored prior to CMake 3.24. +if("FATAL_ERROR" IN_LIST Vulkan_FIND_COMPONENTS) + message(AUTHOR_WARNING + "Ignoring unknown component 'FATAL_ERROR'.\n" + "The find_package() command documents no such argument." + ) + list(REMOVE_ITEM Vulkan_FIND_COMPONENTS "FATAL_ERROR") +endif() + +# FindVulkan only works correctly with the default CMAKE_FIND_FRAMEWORK +# value: FIRST. If LAST it will find the macOS dylibs instead of the iOS +# frameworks when IOS is true. If ALWAYS it will fail to find the macOS +# dylibs. If NEVER it will fail to find the iOS frameworks. If frameworks +# are ever included in the SDK for macOS, the search mechanism will need +# revisiting. +if(DEFINED CMAKE_FIND_FRAMEWORK) + set(_Vulkan_saved_cmake_find_framework ${CMAKE_FIND_FRAMEWORK}) + set(CMAKE_FIND_FRAMEWORK FIRST) +endif() + +if(IOS) + get_filename_component(Vulkan_Target_SDK "$ENV{VULKAN_SDK}/.." REALPATH) + list(APPEND CMAKE_FRAMEWORK_PATH "${Vulkan_Target_SDK}/iOS/lib") + set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) + set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) + set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) +endif() + +# For backward compatibility as `FindVulkan` in previous CMake versions allow to retrieve `glslc` +# and `glslangValidator` without requesting the corresponding component. +if(NOT glslc IN_LIST Vulkan_FIND_COMPONENTS) + list(APPEND Vulkan_FIND_COMPONENTS glslc) +endif() +if(NOT glslangValidator IN_LIST Vulkan_FIND_COMPONENTS) + list(APPEND Vulkan_FIND_COMPONENTS glslangValidator) +endif() + +if(WIN32) + set(_Vulkan_library_name vulkan-1) + set(_Vulkan_hint_include_search_paths + "$ENV{VULKAN_SDK}/include" + ) + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(_Vulkan_hint_executable_search_paths + "$ENV{VULKAN_SDK}/bin" + ) + set(_Vulkan_hint_library_search_paths + "$ENV{VULKAN_SDK}/lib" + "$ENV{VULKAN_SDK}/bin" + ) + else() + set(_Vulkan_hint_executable_search_paths + "$ENV{VULKAN_SDK}/bin32" + "$ENV{VULKAN_SDK}/bin" + ) + set(_Vulkan_hint_library_search_paths + "$ENV{VULKAN_SDK}/lib32" + "$ENV{VULKAN_SDK}/bin32" + "$ENV{VULKAN_SDK}/lib" + "$ENV{VULKAN_SDK}/bin" + ) + endif() +else() + set(_Vulkan_library_name vulkan) + set(_Vulkan_hint_include_search_paths + "$ENV{VULKAN_SDK}/include" + ) + set(_Vulkan_hint_executable_search_paths + "$ENV{VULKAN_SDK}/bin" + ) + set(_Vulkan_hint_library_search_paths + "$ENV{VULKAN_SDK}/lib" + ) +endif() +if(APPLE AND DEFINED Vulkan_Target_SDK) + list(APPEND _Vulkan_hint_include_search_paths + "${Vulkan_Target_SDK}/macOS/include" + ) + if(CMAKE_SYSTEM_NAME STREQUAL "iOS") + list(APPEND _Vulkan_hint_library_search_paths + "${Vulkan_Target_SDK}/iOS/lib" + ) + elseif(CMAKE_SYSTEM_NAME STREQUAL "tvOS") + list(APPEND _Vulkan_hint_library_search_paths + "${Vulkan_Target_SDK}/tvOS/lib" + ) + else() + list(APPEND _Vulkan_hint_library_search_paths + "${Vulkan_Target_SDK}/lib" + ) + endif() +endif() + +find_path(Vulkan_INCLUDE_DIR + NAMES vulkan/vulkan.h + HINTS + ${_Vulkan_hint_include_search_paths} +) +mark_as_advanced(Vulkan_INCLUDE_DIR) + +find_library(Vulkan_LIBRARY + NAMES ${_Vulkan_library_name} + HINTS + ${_Vulkan_hint_library_search_paths} +) +#message(STATUS "vulkan_library ${Vulkan_LIBRARY} search paths ${_Vulkan_hint_library_search_paths}") +mark_as_advanced(Vulkan_LIBRARY) + +find_library(Vulkan_Layer_API_DUMP + NAMES VkLayer_api_dump + HINTS + ${_Vulkan_hint_library_search_paths} +) +mark_as_advanced(Vulkan_Layer_API_DUMP) + +find_library(Vulkan_Layer_SHADER_OBJECT + NAMES VkLayer_khronos_shader_object + HINTS + ${_Vulkan_hint_library_search_paths} +) +mark_as_advanced(VkLayer_khronos_shader_object) + +find_library(Vulkan_Layer_SYNC2 + NAMES VkLayer_khronos_synchronization2 + HINTS + ${_Vulkan_hint_library_search_paths} +) +mark_as_advanced(Vulkan_Layer_SYNC2) + +find_library(Vulkan_Layer_VALIDATION + NAMES VkLayer_khronos_validation + HINTS + ${_Vulkan_hint_library_search_paths} +) +mark_as_advanced(Vulkan_Layer_VALIDATION) + +if(glslc IN_LIST Vulkan_FIND_COMPONENTS) + find_program(Vulkan_GLSLC_EXECUTABLE + NAMES glslc + HINTS + ${_Vulkan_hint_executable_search_paths} + ) + mark_as_advanced(Vulkan_GLSLC_EXECUTABLE) +endif() +if(glslangValidator IN_LIST Vulkan_FIND_COMPONENTS) + find_program(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE + NAMES glslangValidator + HINTS + ${_Vulkan_hint_executable_search_paths} + ) + mark_as_advanced(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE) +endif() +if(glslang IN_LIST Vulkan_FIND_COMPONENTS) + find_library(Vulkan_glslang-spirv_LIBRARY + NAMES SPIRV + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang-spirv_LIBRARY) + + find_library(Vulkan_glslang-spirv_DEBUG_LIBRARY + NAMES SPIRVd + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang-spirv_DEBUG_LIBRARY) + + find_library(Vulkan_glslang-oglcompiler_LIBRARY + NAMES OGLCompiler + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang-oglcompiler_LIBRARY) + + find_library(Vulkan_glslang-oglcompiler_DEBUG_LIBRARY + NAMES OGLCompilerd + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang-oglcompiler_DEBUG_LIBRARY) + + find_library(Vulkan_glslang-osdependent_LIBRARY + NAMES OSDependent + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang-osdependent_LIBRARY) + + find_library(Vulkan_glslang-osdependent_DEBUG_LIBRARY + NAMES OSDependentd + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang-osdependent_DEBUG_LIBRARY) + + find_library(Vulkan_glslang-machineindependent_LIBRARY + NAMES MachineIndependent + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang-machineindependent_LIBRARY) + + find_library(Vulkan_glslang-machineindependent_DEBUG_LIBRARY + NAMES MachineIndependentd + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang-machineindependent_DEBUG_LIBRARY) + + find_library(Vulkan_glslang-genericcodegen_LIBRARY + NAMES GenericCodeGen + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang-genericcodegen_LIBRARY) + + find_library(Vulkan_glslang-genericcodegen_DEBUG_LIBRARY + NAMES GenericCodeGend + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang-genericcodegen_DEBUG_LIBRARY) + + find_library(Vulkan_glslang_LIBRARY + NAMES glslang + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang_LIBRARY) + + find_library(Vulkan_glslang_DEBUG_LIBRARY + NAMES glslangd + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang_DEBUG_LIBRARY) +endif() +if(shaderc_combined IN_LIST Vulkan_FIND_COMPONENTS) + find_library(Vulkan_shaderc_combined_LIBRARY + NAMES shaderc_combined + HINTS + ${_Vulkan_hint_library_search_paths}) + mark_as_advanced(Vulkan_shaderc_combined_LIBRARY) + + find_library(Vulkan_shaderc_combined_DEBUG_LIBRARY + NAMES shaderc_combinedd + HINTS + ${_Vulkan_hint_library_search_paths}) + mark_as_advanced(Vulkan_shaderc_combined_DEBUG_LIBRARY) +endif() +if(SPIRV-Tools IN_LIST Vulkan_FIND_COMPONENTS) + find_library(Vulkan_SPIRV-Tools_LIBRARY + NAMES SPIRV-Tools + HINTS + ${_Vulkan_hint_library_search_paths}) + mark_as_advanced(Vulkan_SPIRV-Tools_LIBRARY) + + find_library(Vulkan_SPIRV-Tools_DEBUG_LIBRARY + NAMES SPIRV-Toolsd + HINTS + ${_Vulkan_hint_library_search_paths}) + mark_as_advanced(Vulkan_SPIRV-Tools_DEBUG_LIBRARY) +endif() +if(MoltenVK IN_LIST Vulkan_FIND_COMPONENTS) + # CMake has a bug in 3.28 that doesn't handle xcframeworks. Do it by hand for now. + if(CMAKE_SYSTEM_NAME STREQUAL "iOS") + if(CMAKE_VERSION VERSION_LESS 3.29) + set( _Vulkan_hint_library_search_paths ${Vulkan_Target_SDK}/ios/lib/MoltenVK.xcframework/ios-arm64) + else () + set( _Vulkan_hint_library_search_paths ${Vulkan_Target_SDK}/ios/lib/) + endif () + endif () + find_library(Vulkan_MoltenVK_LIBRARY + NAMES MoltenVK + NO_DEFAULT_PATH + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_MoltenVK_LIBRARY) + + find_path(Vulkan_MoltenVK_INCLUDE_DIR + NAMES MoltenVK/mvk_vulkan.h + HINTS + ${_Vulkan_hint_include_search_paths} + ) + mark_as_advanced(Vulkan_MoltenVK_INCLUDE_DIR) +endif() +if(volk IN_LIST Vulkan_FIND_COMPONENTS) + find_library(Vulkan_volk_LIBRARY + NAMES volk + HINTS + ${_Vulkan_hint_library_search_paths}) + mark_as_advanced(Vulkan_Volk_LIBRARY) +endif() + +if (dxc IN_LIST Vulkan_FIND_COMPONENTS) + find_library(Vulkan_dxc_LIBRARY + NAMES dxcompiler + HINTS + ${_Vulkan_hint_library_search_paths}) + mark_as_advanced(Vulkan_dxc_LIBRARY) + + find_program(Vulkan_dxc_EXECUTABLE + NAMES dxc + HINTS + ${_Vulkan_hint_executable_search_paths}) + mark_as_advanced(Vulkan_dxc_EXECUTABLE) +endif() + +if(DEFINED _Vulkan_saved_cmake_find_framework) + set(CMAKE_FIND_FRAMEWORK ${_Vulkan_saved_cmake_find_framework}) + unset(_Vulkan_saved_cmake_find_framework) +endif() + +if(Vulkan_GLSLC_EXECUTABLE) + set(Vulkan_glslc_FOUND TRUE) +else() + set(Vulkan_glslc_FOUND FALSE) +endif() + +if(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE) + set(Vulkan_glslangValidator_FOUND TRUE) +else() + set(Vulkan_glslangValidator_FOUND FALSE) +endif() + +if (Vulkan_dxc_EXECUTABLE) + set(Vulkan_dxc_exe_FOUND TRUE) +else() + set(Vulkan_dxc_exe_FOUND FALSE) +endif() + +function(_Vulkan_set_library_component_found component) + cmake_parse_arguments(PARSE_ARGV 1 _ARG + "NO_WARNING" + "" + "DEPENDENT_COMPONENTS") + + set(all_dependent_component_found TRUE) + foreach(dependent_component IN LISTS _ARG_DEPENDENT_COMPONENTS) + if(NOT Vulkan_${dependent_component}_FOUND) + set(all_dependent_component_found FALSE) + break() + endif() + endforeach() + + if(all_dependent_component_found AND (Vulkan_${component}_LIBRARY OR Vulkan_${component}_DEBUG_LIBRARY)) + set(Vulkan_${component}_FOUND TRUE PARENT_SCOPE) + + # For Windows Vulkan SDK, third party tools binaries are provided with different MSVC ABI: + # - Release binaries uses a runtime library + # - Debug binaries uses a debug runtime library + # This lead to incompatibilities in linking for some configuration types due to CMake-default or project-configured selected MSVC ABI. + if(WIN32 AND NOT _ARG_NO_WARNING) + if(NOT Vulkan_${component}_LIBRARY) + message(WARNING + "Library ${component} for Release configuration is missing, imported target Vulkan::${component} may not be able to link when targeting this build configuration due to incompatible MSVC ABI.") + endif() + if(NOT Vulkan_${component}_DEBUG_LIBRARY) + message(WARNING + "Library ${component} for Debug configuration is missing, imported target Vulkan::${component} may not be able to link when targeting this build configuration due to incompatible MSVC ABI. Consider re-installing the Vulkan SDK and request debug libraries to fix this warning.") + endif() + endif() + else() + set(Vulkan_${component}_FOUND FALSE PARENT_SCOPE) + endif() +endfunction() + +_Vulkan_set_library_component_found(glslang-spirv NO_WARNING) +_Vulkan_set_library_component_found(glslang-oglcompiler NO_WARNING) +_Vulkan_set_library_component_found(glslang-osdependent NO_WARNING) +_Vulkan_set_library_component_found(glslang-machineindependent NO_WARNING) +_Vulkan_set_library_component_found(glslang-genericcodegen NO_WARNING) +_Vulkan_set_library_component_found(glslang + DEPENDENT_COMPONENTS + glslang-spirv + glslang-oglcompiler + glslang-osdependent + glslang-machineindependent + glslang-genericcodegen) +_Vulkan_set_library_component_found(shaderc_combined) +_Vulkan_set_library_component_found(SPIRV-Tools) +_Vulkan_set_library_component_found(volk) +_Vulkan_set_library_component_found(dxc) + +if(Vulkan_MoltenVK_INCLUDE_DIR AND Vulkan_MoltenVK_LIBRARY) + set(Vulkan_MoltenVK_FOUND TRUE) +else() + set(Vulkan_MoltenVK_FOUND FALSE) +endif() + +set(Vulkan_LIBRARIES ${Vulkan_LIBRARY}) +set(Vulkan_INCLUDE_DIRS ${Vulkan_INCLUDE_DIR}) + +# detect version e.g 1.2.189 +set(Vulkan_VERSION "") +if(Vulkan_INCLUDE_DIR) + set(VULKAN_CORE_H ${Vulkan_INCLUDE_DIR}/vulkan/vulkan_core.h) + if(EXISTS ${VULKAN_CORE_H}) + file(STRINGS ${VULKAN_CORE_H} VulkanHeaderVersionLine REGEX "^#define VK_HEADER_VERSION ") + string(REGEX MATCHALL "[0-9]+" VulkanHeaderVersion "${VulkanHeaderVersionLine}") + file(STRINGS ${VULKAN_CORE_H} VulkanHeaderVersionLine2 REGEX "^#define VK_HEADER_VERSION_COMPLETE ") + string(REGEX MATCHALL "[0-9]+" VulkanHeaderVersion2 "${VulkanHeaderVersionLine2}") + list(LENGTH VulkanHeaderVersion2 _len) + # versions >= 1.2.175 have an additional numbers in front of e.g. '0, 1, 2' instead of '1, 2' + if(_len EQUAL 3) + list(REMOVE_AT VulkanHeaderVersion2 0) + endif() + list(APPEND VulkanHeaderVersion2 ${VulkanHeaderVersion}) + list(JOIN VulkanHeaderVersion2 "." Vulkan_VERSION) + endif() +endif() + +if(Vulkan_MoltenVK_FOUND) + set(Vulkan_MoltenVK_VERSION "") + if(Vulkan_MoltenVK_INCLUDE_DIR) + set(VK_MVK_MOLTENVK_H ${Vulkan_MoltenVK_INCLUDE_DIR}/MoltenVK/vk_mvk_moltenvk.h) + if(EXISTS ${VK_MVK_MOLTENVK_H}) + file(STRINGS ${VK_MVK_MOLTENVK_H} _Vulkan_MoltenVK_VERSION_MAJOR REGEX "^#define MVK_VERSION_MAJOR ") + string(REGEX MATCHALL "[0-9]+" _Vulkan_MoltenVK_VERSION_MAJOR "${_Vulkan_MoltenVK_VERSION_MAJOR}") + file(STRINGS ${VK_MVK_MOLTENVK_H} _Vulkan_MoltenVK_VERSION_MINOR REGEX "^#define MVK_VERSION_MINOR ") + string(REGEX MATCHALL "[0-9]+" _Vulkan_MoltenVK_VERSION_MINOR "${_Vulkan_MoltenVK_VERSION_MINOR}") + file(STRINGS ${VK_MVK_MOLTENVK_H} _Vulkan_MoltenVK_VERSION_PATCH REGEX "^#define MVK_VERSION_PATCH ") + string(REGEX MATCHALL "[0-9]+" _Vulkan_MoltenVK_VERSION_PATCH "${_Vulkan_MoltenVK_VERSION_PATCH}") + set(Vulkan_MoltenVK_VERSION "${_Vulkan_MoltenVK_VERSION_MAJOR}.${_Vulkan_MoltenVK_VERSION_MINOR}.${_Vulkan_MoltenVK_VERSION_PATCH}") + unset(_Vulkan_MoltenVK_VERSION_MAJOR) + unset(_Vulkan_MoltenVK_VERSION_MINOR) + unset(_Vulkan_MoltenVK_VERSION_PATCH) + endif() + endif() +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Vulkan + REQUIRED_VARS + Vulkan_LIBRARY + Vulkan_INCLUDE_DIR + VERSION_VAR + Vulkan_VERSION + HANDLE_COMPONENTS +) + +if(Vulkan_FOUND AND NOT TARGET Vulkan::Vulkan) + add_library(Vulkan::Vulkan UNKNOWN IMPORTED) + get_filename_component(_Vulkan_lib_extension ${Vulkan_LIBRARIES} LAST_EXT) + if(_Vulkan_lib_extension STREQUAL ".framework" AND CMAKE_VERSION VERSION_LESS 3.28) + set_target_properties(Vulkan::Vulkan PROPERTIES + # Prior to 3.28 must reference library just inside the framework. + IMPORTED_LOCATION "${Vulkan_LIBRARIES}/vulkan") + else() + set_target_properties(Vulkan::Vulkan PROPERTIES + IMPORTED_LOCATION "${Vulkan_LIBRARIES}") + endif() + set_target_properties(Vulkan::Vulkan PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") + unset(_Vulkan_lib_extension) +endif() + +if(Vulkan_FOUND AND NOT TARGET Vulkan::Headers) + add_library(Vulkan::Headers INTERFACE IMPORTED) + set_target_properties(Vulkan::Headers PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") +endif() + +if(Vulkan_FOUND AND Vulkan_GLSLC_EXECUTABLE AND NOT TARGET Vulkan::glslc) + add_executable(Vulkan::glslc IMPORTED) + set_property(TARGET Vulkan::glslc PROPERTY IMPORTED_LOCATION "${Vulkan_GLSLC_EXECUTABLE}") +endif() + +if(Vulkan_FOUND AND Vulkan_GLSLANG_VALIDATOR_EXECUTABLE AND NOT TARGET Vulkan::glslangValidator) + add_executable(Vulkan::glslangValidator IMPORTED) + set_property(TARGET Vulkan::glslangValidator PROPERTY IMPORTED_LOCATION "${Vulkan_GLSLANG_VALIDATOR_EXECUTABLE}") +endif() + +if(Vulkan_FOUND) + if((Vulkan_glslang-spirv_LIBRARY OR Vulkan_glslang-spirv_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-spirv) + add_library(Vulkan::glslang-spirv STATIC IMPORTED) + set_property(TARGET Vulkan::glslang-spirv + PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") + if(Vulkan_glslang-spirv_LIBRARY) + set_property(TARGET Vulkan::glslang-spirv APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Release) + set_property(TARGET Vulkan::glslang-spirv + PROPERTY + IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-spirv_LIBRARY}") + endif() + if(Vulkan_glslang-spirv_DEBUG_LIBRARY) + set_property(TARGET Vulkan::glslang-spirv APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Debug) + set_property(TARGET Vulkan::glslang-spirv + PROPERTY + IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-spirv_DEBUG_LIBRARY}") + endif() + endif() + + if((Vulkan_glslang-oglcompiler_LIBRARY OR Vulkan_glslang-oglcompiler_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-oglcompiler) + add_library(Vulkan::glslang-oglcompiler STATIC IMPORTED) + set_property(TARGET Vulkan::glslang-oglcompiler + PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") + if(Vulkan_glslang-oglcompiler_LIBRARY) + set_property(TARGET Vulkan::glslang-oglcompiler APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Release) + set_property(TARGET Vulkan::glslang-oglcompiler + PROPERTY + IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-oglcompiler_LIBRARY}") + endif() + if(Vulkan_glslang-oglcompiler_DEBUG_LIBRARY) + set_property(TARGET Vulkan::glslang-oglcompiler APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Debug) + set_property(TARGET Vulkan::glslang-oglcompiler + PROPERTY + IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-oglcompiler_DEBUG_LIBRARY}") + endif() + endif() + + if((Vulkan_glslang-osdependent_LIBRARY OR Vulkan_glslang-osdependent_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-osdependent) + add_library(Vulkan::glslang-osdependent STATIC IMPORTED) + set_property(TARGET Vulkan::glslang-osdependent + PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") + if(Vulkan_glslang-osdependent_LIBRARY) + set_property(TARGET Vulkan::glslang-osdependent APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Release) + set_property(TARGET Vulkan::glslang-osdependent + PROPERTY + IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-osdependent_LIBRARY}") + endif() + if(Vulkan_glslang-osdependent_DEBUG_LIBRARY) + set_property(TARGET Vulkan::glslang-osdependent APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Debug) + set_property(TARGET Vulkan::glslang-osdependent + PROPERTY + IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-osdependent_DEBUG_LIBRARY}") + endif() + endif() + + if((Vulkan_glslang-machineindependent_LIBRARY OR Vulkan_glslang-machineindependent_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-machineindependent) + add_library(Vulkan::glslang-machineindependent STATIC IMPORTED) + set_property(TARGET Vulkan::glslang-machineindependent + PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") + if(Vulkan_glslang-machineindependent_LIBRARY) + set_property(TARGET Vulkan::glslang-machineindependent APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Release) + set_property(TARGET Vulkan::glslang-machineindependent + PROPERTY + IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-machineindependent_LIBRARY}") + endif() + if(Vulkan_glslang-machineindependent_DEBUG_LIBRARY) + set_property(TARGET Vulkan::glslang-machineindependent APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Debug) + set_property(TARGET Vulkan::glslang-machineindependent + PROPERTY + IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-machineindependent_DEBUG_LIBRARY}") + endif() + endif() + + if((Vulkan_glslang-genericcodegen_LIBRARY OR Vulkan_glslang-genericcodegen_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-genericcodegen) + add_library(Vulkan::glslang-genericcodegen STATIC IMPORTED) + set_property(TARGET Vulkan::glslang-genericcodegen + PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") + if(Vulkan_glslang-genericcodegen_LIBRARY) + set_property(TARGET Vulkan::glslang-genericcodegen APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Release) + set_property(TARGET Vulkan::glslang-genericcodegen + PROPERTY + IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-genericcodegen_LIBRARY}") + endif() + if(Vulkan_glslang-genericcodegen_DEBUG_LIBRARY) + set_property(TARGET Vulkan::glslang-genericcodegen APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Debug) + set_property(TARGET Vulkan::glslang-genericcodegen + PROPERTY + IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-genericcodegen_DEBUG_LIBRARY}") + endif() + endif() + + if((Vulkan_glslang_LIBRARY OR Vulkan_glslang_DEBUG_LIBRARY) + AND TARGET Vulkan::glslang-spirv + AND TARGET Vulkan::glslang-oglcompiler + AND TARGET Vulkan::glslang-osdependent + AND TARGET Vulkan::glslang-machineindependent + AND TARGET Vulkan::glslang-genericcodegen + AND NOT TARGET Vulkan::glslang) + add_library(Vulkan::glslang STATIC IMPORTED) + set_property(TARGET Vulkan::glslang + PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") + if(Vulkan_glslang_LIBRARY) + set_property(TARGET Vulkan::glslang APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Release) + set_property(TARGET Vulkan::glslang + PROPERTY + IMPORTED_LOCATION_RELEASE "${Vulkan_glslang_LIBRARY}") + endif() + if(Vulkan_glslang_DEBUG_LIBRARY) + set_property(TARGET Vulkan::glslang APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Debug) + set_property(TARGET Vulkan::glslang + PROPERTY + IMPORTED_LOCATION_DEBUG "${Vulkan_glslang_DEBUG_LIBRARY}") + endif() + target_link_libraries(Vulkan::glslang + INTERFACE + Vulkan::glslang-spirv + Vulkan::glslang-oglcompiler + Vulkan::glslang-osdependent + Vulkan::glslang-machineindependent + Vulkan::glslang-genericcodegen + ) + endif() + + if((Vulkan_shaderc_combined_LIBRARY OR Vulkan_shaderc_combined_DEBUG_LIBRARY) AND NOT TARGET Vulkan::shaderc_combined) + add_library(Vulkan::shaderc_combined STATIC IMPORTED) + set_property(TARGET Vulkan::shaderc_combined + PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") + if(Vulkan_shaderc_combined_LIBRARY) + set_property(TARGET Vulkan::shaderc_combined APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Release) + set_property(TARGET Vulkan::shaderc_combined + PROPERTY + IMPORTED_LOCATION_RELEASE "${Vulkan_shaderc_combined_LIBRARY}") + endif() + if(Vulkan_shaderc_combined_DEBUG_LIBRARY) + set_property(TARGET Vulkan::shaderc_combined APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Debug) + set_property(TARGET Vulkan::shaderc_combined + PROPERTY + IMPORTED_LOCATION_DEBUG "${Vulkan_shaderc_combined_DEBUG_LIBRARY}") + endif() + + if(UNIX) + find_package(Threads REQUIRED) + target_link_libraries(Vulkan::shaderc_combined + INTERFACE + Threads::Threads) + endif() + endif() + + if((Vulkan_SPIRV-Tools_LIBRARY OR Vulkan_SPIRV-Tools_DEBUG_LIBRARY) AND NOT TARGET Vulkan::SPIRV-Tools) + add_library(Vulkan::SPIRV-Tools STATIC IMPORTED) + set_property(TARGET Vulkan::SPIRV-Tools + PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") + if(Vulkan_SPIRV-Tools_LIBRARY) + set_property(TARGET Vulkan::SPIRV-Tools APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Release) + set_property(TARGET Vulkan::SPIRV-Tools + PROPERTY + IMPORTED_LOCATION_RELEASE "${Vulkan_SPIRV-Tools_LIBRARY}") + endif() + if(Vulkan_SPIRV-Tools_DEBUG_LIBRARY) + set_property(TARGET Vulkan::SPIRV-Tools APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Debug) + set_property(TARGET Vulkan::SPIRV-Tools + PROPERTY + IMPORTED_LOCATION_DEBUG "${Vulkan_SPIRV-Tools_DEBUG_LIBRARY}") + endif() + endif() + + if(Vulkan_volk_LIBRARY AND NOT TARGET Vulkan::volk) + add_library(Vulkan::volk STATIC IMPORTED) + set_property(TARGET Vulkan::volk + PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") + set_property(TARGET Vulkan::volk APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Release) + set_property(TARGET Vulkan::volk APPEND + PROPERTY + IMPORTED_LOCATION_RELEASE "${Vulkan_volk_LIBRARY}") + + if (NOT WIN32) + set_property(TARGET Vulkan::volk APPEND + PROPERTY + IMPORTED_LINK_INTERFACE_LIBRARIES dl) + endif() + endif() + + if (Vulkan_dxc_LIBRARY AND NOT TARGET Vulkan::dxc_lib) + add_library(Vulkan::dxc_lib STATIC IMPORTED) + set_property(TARGET Vulkan::dxc_lib + PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") + set_property(TARGET Vulkan::dxc_lib APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Release) + set_property(TARGET Vulkan::dxc_lib APPEND + PROPERTY + IMPORTED_LOCATION_RELEASE "${Vulkan_dxc_LIBRARY}") + endif() + + if(Vulkan_dxc_EXECUTABLE AND NOT TARGET Vulkan::dxc_exe) + add_executable(Vulkan::dxc_exe IMPORTED) + set_property(TARGET Vulkan::dxc_exe PROPERTY IMPORTED_LOCATION "${Vulkan_dxc_EXECUTABLE}") + endif() + +endif() + +if(Vulkan_MoltenVK_FOUND) + if(Vulkan_MoltenVK_LIBRARY AND NOT TARGET Vulkan::MoltenVK) + add_library(Vulkan::MoltenVK SHARED IMPORTED) + set_target_properties(Vulkan::MoltenVK + PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_MoltenVK_INCLUDE_DIR}" + IMPORTED_LOCATION "${Vulkan_MoltenVK_LIBRARY}" + ) + endif() +endif() + +unset(_Vulkan_library_name) +unset(_Vulkan_hint_include_search_paths) +unset(_Vulkan_hint_executable_search_paths) +unset(_Vulkan_hint_library_search_paths) + +cmake_policy(POP) From c7b2b43b43157d11e9c5fb33a30d00ac87a5b4ce Mon Sep 17 00:00:00 2001 From: "Giancane, Francesco" Date: Fri, 6 Mar 2026 12:07:28 +0000 Subject: [PATCH 06/11] Revert "bldsys/toolchain: introduce `ios.cmake` toolchain file" This reverts commit 6f1680fda533017a62e8ea071cf8a14c18c2b9f1. --- bldsys/toolchain/ios.cmake | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 bldsys/toolchain/ios.cmake diff --git a/bldsys/toolchain/ios.cmake b/bldsys/toolchain/ios.cmake deleted file mode 100644 index 28d4a9d23e..0000000000 --- a/bldsys/toolchain/ios.cmake +++ /dev/null @@ -1,12 +0,0 @@ -# As per upstream CMake recommendation in https://gitlab.kitware.com/cmake/cmake/-/issues/27661 -# to properly build for iOS we need a toolchain file. -# Toolchain file shall define: -# - Target system name to iOS -# - Export the $ENV{VULKAN_SDK} variable to `CMAKE_FIND_ROOT_PATH` -# iOS/setup-env.sh will take care of setting proper environment. - -set(CMAKE_SYSTEM_NAME iOS) -set(CMAKE_OSX_SYSROOT iphoneos) -set(CMAKE_OSX_DEPLOYMENT_TARGET 16.3) -set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED NO) -list(APPEND CMAKE_FIND_ROOT_PATH "$ENV{VULKAN_SDK}") From 9c2eb4a3618fd7d101d58b51caf09d3840015b26 Mon Sep 17 00:00:00 2001 From: "Giancane, Francesco" Date: Fri, 6 Mar 2026 12:07:55 +0000 Subject: [PATCH 07/11] Revert "build.yml: update workflow for iOS CI to use ios toolchain file" This reverts commit 265d31356e127a5c071034f325b79137cbee71ff. --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0a1cd20986..5a78261d1d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -194,5 +194,5 @@ jobs: - name: build_ios run: | source ~/VulkanSDK/iOS/setup-env.sh - cmake -H"." -B"build/ios" -DVKB_BUILD_TESTS=ON -DVKB_BUILD_SAMPLES=ON -G Xcode --toolchain bldsys/toolchain/ios.cmake + cmake -H"." -B"build/ios" -DVKB_BUILD_TESTS=ON -DVKB_BUILD_SAMPLES=ON -G Xcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_DEPLOYMENT_TARGET=16.3 -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED=NO cmake --build "build/ios" --target vulkan_samples --config ${{ matrix.build_type }} -- -allowProvisioningUpdates From a6ef4f0369dba359cf2fcd62f8fc5801194903d1 Mon Sep 17 00:00:00 2001 From: "Giancane, Francesco" Date: Fri, 6 Mar 2026 13:55:19 +0000 Subject: [PATCH 08/11] bldsys/cmake/module/FindVulkan.cmake: Backport upstream changes Backport these patches into our downstream `FindVulkan` CMake module: 5e1440302a FindVulkan: Add support for cross-compiling between Windows x64/ARM64 f9a09f76f3 FindVulkan: Drop support for 32-bit SDK on Windows b40740f28a FindVulkan: Do not search bin directories for libraries 947adbba91 FindVulkan: Use ENV{VULKAN_SDK} only if it exists This allows proper libraries discovery of Vulkan Libraries on Windows, both for x86_64 and ARM64 targets. Co-Authored-By: Brad King Tested-By: Giancane, Francesco --- bldsys/cmake/module/FindVulkan.cmake | 107 ++++++++++++++++----------- 1 file changed, 64 insertions(+), 43 deletions(-) diff --git a/bldsys/cmake/module/FindVulkan.cmake b/bldsys/cmake/module/FindVulkan.cmake index 526301938d..dcbffb4384 100644 --- a/bldsys/cmake/module/FindVulkan.cmake +++ b/bldsys/cmake/module/FindVulkan.cmake @@ -263,57 +263,78 @@ endif() if(WIN32) set(_Vulkan_library_name vulkan-1) - set(_Vulkan_hint_include_search_paths - "$ENV{VULKAN_SDK}/include" - ) - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(_Vulkan_hint_executable_search_paths - "$ENV{VULKAN_SDK}/bin" - ) - set(_Vulkan_hint_library_search_paths - "$ENV{VULKAN_SDK}/lib" - "$ENV{VULKAN_SDK}/bin" - ) - else() - set(_Vulkan_hint_executable_search_paths - "$ENV{VULKAN_SDK}/bin32" - "$ENV{VULKAN_SDK}/bin" - ) - set(_Vulkan_hint_library_search_paths - "$ENV{VULKAN_SDK}/lib32" - "$ENV{VULKAN_SDK}/bin32" - "$ENV{VULKAN_SDK}/lib" - "$ENV{VULKAN_SDK}/bin" - ) - endif() else() set(_Vulkan_library_name vulkan) +endif() +set(_Vulkan_hint_include_search_paths "") +set(_Vulkan_hint_executable_search_paths "") +set(_Vulkan_hint_library_search_paths "") + +if(DEFINED ENV{VULKAN_SDK} AND IS_DIRECTORY "$ENV{VULKAN_SDK}") set(_Vulkan_hint_include_search_paths - "$ENV{VULKAN_SDK}/include" + "$ENV{VULKAN_SDK}/include" ) set(_Vulkan_hint_executable_search_paths - "$ENV{VULKAN_SDK}/bin" + "$ENV{VULKAN_SDK}/bin" ) + if(WIN32) + # Detect the target architecture from one of: + # - the C++ compiler, + # - the C compiler, + # - the VS generator, + # - the command-line environment, + # - fallback to CMAKE_SYSTEM_PROCESSOR. + if(CMAKE_CXX_COMPILER_LOADED AND CMAKE_CXX_COMPILER_ARCHITECTURE_ID) + set(_Vulkan_arch_name "${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}") + elseif(CMAKE_C_COMPILER_LOADED AND CMAKE_C_COMPILER_ARCHITECTURE_ID) + set(_Vulkan_arch_name "${CMAKE_C_COMPILER_ARCHITECTURE_ID}") + elseif(CMAKE_VS_PLATFORM_NAME) + set(_Vulkan_arch_name "${CMAKE_VS_PLATFORM_NAME}") + elseif(DEFINED ENV{VSCMD_ARG_TGT_ARCH}) + set(_Vulkan_arch_name "$ENV{VSCMD_ARG_TGT_ARCH}") + elseif(CMAKE_SYSTEM_PROCESSOR) + set(_Vulkan_arch_name "${CMAKE_SYSTEM_PROCESSOR}") + endif() + # The Vulkan SDK may provide arch-specific directories for cross-compiling. + if(_Vulkan_arch_name MATCHES "^(ARM64|arm64|aarch64)" AND IS_DIRECTORY "$ENV{VULKAN_SDK}/lib-arm64") + # On X64 hosts the Vulkan SDK provides `-arm64` dirs for cross-compiling to ARM64. + set(_Vulkan_arch_suffix "-arm64") + elseif(_Vulkan_arch_name MATCHES "^(X64|x64|x86_64)" AND IS_DIRECTORY "$ENV{VULKAN_SDK}/lib-x64") + # On ARM64 hosts the Vulkan SDK provides `-x64` dirs for cross-compiling to x64. + set(_Vulkan_arch_suffix "-x64") + else() + # Otherwise assume we are compiling for the host. + set(_Vulkan_arch_suffix "") + endif() + unset(_Vulkan_arch_name) + else() + set(_Vulkan_arch_suffix "") + endif() set(_Vulkan_hint_library_search_paths - "$ENV{VULKAN_SDK}/lib" - ) -endif() -if(APPLE AND DEFINED Vulkan_Target_SDK) - list(APPEND _Vulkan_hint_include_search_paths - "${Vulkan_Target_SDK}/macOS/include" + "$ENV{VULKAN_SDK}/lib${_Vulkan_arch_suffix}" ) - if(CMAKE_SYSTEM_NAME STREQUAL "iOS") - list(APPEND _Vulkan_hint_library_search_paths - "${Vulkan_Target_SDK}/iOS/lib" - ) - elseif(CMAKE_SYSTEM_NAME STREQUAL "tvOS") - list(APPEND _Vulkan_hint_library_search_paths - "${Vulkan_Target_SDK}/tvOS/lib" - ) - else() - list(APPEND _Vulkan_hint_library_search_paths - "${Vulkan_Target_SDK}/lib" - ) + unset(_Vulkan_arch_suffix) + if(APPLE) + cmake_path(SET _MoltenVK_path NORMALIZE "$ENV{VULKAN_SDK}/../MoltenVK") + if(IS_DIRECTORY "${_MoltenVK_path}") + list(APPEND _Vulkan_hint_include_search_paths + "${_MoltenVK_path}/include" + ) + if(CMAKE_SYSTEM_NAME STREQUAL "iOS") + list(APPEND _Vulkan_hint_library_search_paths + "${_MoltenVK_path}/dylib/iOS" + ) + elseif(CMAKE_SYSTEM_NAME STREQUAL "tvOS") + list(APPEND _Vulkan_hint_library_search_paths + "${_MoltenVK_path}/dylib/tvOS" + ) + else() + list(APPEND _Vulkan_hint_library_search_paths + "${_MoltenVK_path}/dylib/macOS" + ) + endif() + endif() + unset(_MoltenVK_path) endif() endif() From 5e92e7faf22bb89c11ae7f4d1937618312b21751 Mon Sep 17 00:00:00 2001 From: "Giancane, Francesco" Date: Mon, 9 Mar 2026 18:38:33 +0000 Subject: [PATCH 09/11] Fix wrong copyright years. Add license attributions for my changes. --- app/CMakeLists.txt | 3 ++- bldsys/cmake/module/FindVulkan.cmake | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 8dc3ebea43..267eadda77 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -1,4 +1,5 @@ -# Copyright (c) 2019-2025, Arm Limited and Contributors +# Copyright (c) 2019-2026, Arm Limited and Contributors +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. # # SPDX-License-Identifier: Apache-2.0 # diff --git a/bldsys/cmake/module/FindVulkan.cmake b/bldsys/cmake/module/FindVulkan.cmake index dcbffb4384..442ba9120a 100644 --- a/bldsys/cmake/module/FindVulkan.cmake +++ b/bldsys/cmake/module/FindVulkan.cmake @@ -1,4 +1,5 @@ -# Updates for iOS Copyright (c) 2024, Holochip Inc. +# Updates for iOS Copyright (c) 2024-2026, Holochip Inc. +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. From 7206f99b1b26a849d938729bd500cfc8a841738f Mon Sep 17 00:00:00 2001 From: "Giancane, Francesco" Date: Fri, 27 Mar 2026 12:59:20 +0000 Subject: [PATCH 10/11] app/CMakeLists.txt: restore file to its original content Changes are addressed in #1500. --- app/CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 267eadda77..22c817f0ce 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -1,5 +1,4 @@ -# Copyright (c) 2019-2026, Arm Limited and Contributors -# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# Copyright (c) 2019-2025, Arm Limited and Contributors # # SPDX-License-Identifier: Apache-2.0 # @@ -138,7 +137,6 @@ if(IOS) endif () # Vulkan cache variables already defined by main project CMakeLists and updated on Apple platforms by global_options.cmake if(Vulkan_LIBRARY AND ${Vulkan_VERSION} VERSION_GREATER_EQUAL 1.3.278) - get_filename_component(Vulkan_Target_SDK "$ENV{VULKAN_SDK}/.." REALPATH) target_sources(${PROJECT_NAME} PRIVATE ${Vulkan_Target_SDK}/iOS/share/vulkan ) From 1765f77178564bc2234e2a621fef0573a6067e37 Mon Sep 17 00:00:00 2001 From: "Giancane, Francesco" Date: Fri, 27 Mar 2026 13:08:40 +0000 Subject: [PATCH 11/11] bldsys/cmake/module/FindVulkan.cmake: restore if(APPLE) branch As per request on the discussion thread, let's just import the changes required to build Vulkan Samples on Windows/Windows on ARM64. --- bldsys/cmake/module/FindVulkan.cmake | 38 +++++++++++++--------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/bldsys/cmake/module/FindVulkan.cmake b/bldsys/cmake/module/FindVulkan.cmake index 442ba9120a..871b19aa14 100644 --- a/bldsys/cmake/module/FindVulkan.cmake +++ b/bldsys/cmake/module/FindVulkan.cmake @@ -315,27 +315,23 @@ if(DEFINED ENV{VULKAN_SDK} AND IS_DIRECTORY "$ENV{VULKAN_SDK}") "$ENV{VULKAN_SDK}/lib${_Vulkan_arch_suffix}" ) unset(_Vulkan_arch_suffix) - if(APPLE) - cmake_path(SET _MoltenVK_path NORMALIZE "$ENV{VULKAN_SDK}/../MoltenVK") - if(IS_DIRECTORY "${_MoltenVK_path}") - list(APPEND _Vulkan_hint_include_search_paths - "${_MoltenVK_path}/include" - ) - if(CMAKE_SYSTEM_NAME STREQUAL "iOS") - list(APPEND _Vulkan_hint_library_search_paths - "${_MoltenVK_path}/dylib/iOS" - ) - elseif(CMAKE_SYSTEM_NAME STREQUAL "tvOS") - list(APPEND _Vulkan_hint_library_search_paths - "${_MoltenVK_path}/dylib/tvOS" - ) - else() - list(APPEND _Vulkan_hint_library_search_paths - "${_MoltenVK_path}/dylib/macOS" - ) - endif() - endif() - unset(_MoltenVK_path) +endif() +if(APPLE AND DEFINED Vulkan_Target_SDK) + list(APPEND _Vulkan_hint_include_search_paths + "${Vulkan_Target_SDK}/macOS/include" + ) + if(CMAKE_SYSTEM_NAME STREQUAL "iOS") + list(APPEND _Vulkan_hint_library_search_paths + "${Vulkan_Target_SDK}/iOS/lib" + ) + elseif(CMAKE_SYSTEM_NAME STREQUAL "tvOS") + list(APPEND _Vulkan_hint_library_search_paths + "${Vulkan_Target_SDK}/tvOS/lib" + ) + else() + list(APPEND _Vulkan_hint_library_search_paths + "${Vulkan_Target_SDK}/lib" + ) endif() endif()