From f1db0ca2518bc4e3e4740f46a41c37715db14b4f Mon Sep 17 00:00:00 2001 From: Amir Masoud Abdol Date: Thu, 29 Jun 2023 13:47:26 +0200 Subject: [PATCH] Look for MoltenVK headers if there are installed separately using Brew Homebrew offers a formula for `vulkan-headers`, which does not include the MoltenVK headers. MoltenVK does include the vulkan headers, but if someone passes the vulkan-headers path to CMAKE_PREFIX_PATH, then our module cannot pick up the MoltenVK headers. Brew's MoltenVK installation is a bit odd as well, as in, one needs to point the CMAKE_PREFIX_PATH to `HOMEBREW_PREFIX/molten-vk/libexec/` instead of the directory head. Pick-to: 6.6 Change-Id: I933faeb16b3f54597e3a0af0af584d79b3c0a344 Reviewed-by: Alexey Edelev Reviewed-by: Alexandru Croitor --- cmake/FindWrapVulkanHeaders.cmake | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/cmake/FindWrapVulkanHeaders.cmake b/cmake/FindWrapVulkanHeaders.cmake index 79f5dfc9758..92510ae0001 100644 --- a/cmake/FindWrapVulkanHeaders.cmake +++ b/cmake/FindWrapVulkanHeaders.cmake @@ -48,6 +48,26 @@ if(Vulkan_INCLUDE_DIR) target_include_directories(WrapVulkanHeaders::WrapVulkanHeaders INTERFACE ${__qt_molten_vk_homebrew_include_path}) endif() + + # Check for homebrew vulkan-headers folder structure + # If instead of molten-vk folder, CMAKE_PREFIX_PATH points to Homebrew's + # vulkan-headers installation, then we will not be able to find molten-vk + # headers. If we assume that user has installed the molten-vk formula as + # well, then we might have a chance to pick it up like this. + if(Vulkan_INCLUDE_DIR MATCHES "/homebrew/Cellar/") + set(__qt_standalone_molten_vk_homebrew_include_path + "${Vulkan_INCLUDE_DIR}/../../../../opt/molten-vk/include") + else() + set(__qt_standalone_molten_vk_homebrew_include_path + "${Vulkan_INCLUDE_DIR}/../../molten-vk/include") + endif() + get_filename_component( + __qt_standalone_molten_vk_homebrew_include_path + "${__qt_standalone_molten_vk_homebrew_include_path}" ABSOLUTE) + if(EXISTS "${__qt_standalone_molten_vk_homebrew_include_path}") + target_include_directories(WrapVulkanHeaders::WrapVulkanHeaders INTERFACE + ${__qt_standalone_molten_vk_homebrew_include_path}) + endif() endif() endif()