Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MacOS Missing Vulkan Library Fix #1215

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions bldsys/cmake/global_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

Expand All @@ -77,7 +83,18 @@ if(APPLE)
endif()
elseif(IOS)
# if not using MoltenVK on iOS, set up global Vulkan Library define for iOS Vulkan loader
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")
Expand Down
Loading