From 90a11a2453510b0d739d93aca734a6848d7d3f9b Mon Sep 17 00:00:00 2001 From: Tom Atkinson Date: Mon, 4 Nov 2024 21:48:48 +0000 Subject: [PATCH 1/2] use existing vulkan lib --- bldsys/cmake/global_options.cmake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bldsys/cmake/global_options.cmake b/bldsys/cmake/global_options.cmake index 96c7addbf..4e9ef4c82 100644 --- a/bldsys/cmake/global_options.cmake +++ b/bldsys/cmake/global_options.cmake @@ -36,6 +36,10 @@ if(APPLE) set(VKB_ENABLE_PORTABILITY ON CACHE BOOL "Enable portability enumeration and subset features in the framework. This is required to be set when running on Apple platforms." FORCE) find_package(Vulkan QUIET OPTIONAL_COMPONENTS MoltenVK) + + message(STATUS "Vulkan library: ${Vulkan_LIBRARY}") + message(STATUS "Vulkan headers: ${Vulkan_INCLUDE_DIR}") + if(USE_MoltenVK OR (IOS AND (NOT Vulkan_MoltenVK_FOUND OR (${CMAKE_OSX_SYSROOT} STREQUAL "iphonesimulator" AND ${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64")))) # if using MoltenVK, or MoltenVK for iOS was not found, or using iOS Simulator on x86_64, look for MoltenVK in the Vulkan SDK and MoltenVK project locations if(NOT Vulkan_MoltenVK_LIBRARY) @@ -51,6 +55,8 @@ if(APPLE) unset(_saved_cmake_find_framework) endif() + message(STATUS "MoltenVK library: ${Vulkan_MoltenVK_LIBRARY}") + if(Vulkan_MoltenVK_LIBRARY) get_filename_component(MoltenVK_LIBRARY_PATH ${Vulkan_MoltenVK_LIBRARY} DIRECTORY) @@ -77,7 +83,7 @@ if(APPLE) endif() elseif(IOS) # if not using MoltenVK on iOS, set up global Vulkan Library define for iOS Vulkan loader - add_compile_definitions(_HPP_VULKAN_LIBRARY="vulkan.framework/vulkan") + add_compile_definitions(_HPP_VULKAN_LIBRARY=${Vulkan_LIBRARY}) endif() if(CMAKE_GENERATOR MATCHES "Xcode") From 9ff943d80adcdacab7b1cc477df2e63097eddf79 Mon Sep 17 00:00:00 2001 From: Tom Atkinson Date: Mon, 4 Nov 2024 22:34:43 +0000 Subject: [PATCH 2/2] add fallback --- bldsys/cmake/global_options.cmake | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/bldsys/cmake/global_options.cmake b/bldsys/cmake/global_options.cmake index 4e9ef4c82..750cafdfe 100644 --- a/bldsys/cmake/global_options.cmake +++ b/bldsys/cmake/global_options.cmake @@ -83,7 +83,18 @@ if(APPLE) endif() elseif(IOS) # if not using MoltenVK on iOS, set up global Vulkan Library define for iOS Vulkan loader - add_compile_definitions(_HPP_VULKAN_LIBRARY=${Vulkan_LIBRARY}) + message(STATUS "Using iOS Vulkan loader") + add_compile_definitions(_HPP_VULKAN_LIBRARY="vulkan.framework/vulkan") + elseif(Vulkan_LIBRARY) + # This is a patch for newer macOS versions where the Vulkan Loader is not found in the default search paths + # In the future this can be removed when the Vulkan SDK is updated to install the loader in the default search paths or when the + # VulkanHPP DynamicLoader is updated to search for the loader in the Vulkan SDK install location + string(FIND "${Vulkan_LIBRARY}" "/usr/local/lib" VULKAN_LIBRARY_PREFIX) + if(VULKAN_LIBRARY_PREFIX EQUAL 0) + message(STATUS "Vulkan found in /usr/local/lib. Patching RPATH.") + set(CMAKE_INSTALL_RPATH "/usr/local/lib;${CMAKE_INSTALL_RPATH}") + set(CMAKE_BUILD_WITH_INSTALL_RPATH ON) + endif() endif() if(CMAKE_GENERATOR MATCHES "Xcode")