From 53f84e39fd8e61f504fc969e16d9c50bf92fed15 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Thu, 22 Jul 2021 16:29:24 +0300 Subject: [PATCH] Fix MoltenVK static linking on macOS (add missing include path, Vulkan SDK path option, use xcframework instead of static framework). --- drivers/vulkan/SCsub | 2 +- platform/osx/detect.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/vulkan/SCsub b/drivers/vulkan/SCsub index 14b9d632042..6a2a57d18c4 100644 --- a/drivers/vulkan/SCsub +++ b/drivers/vulkan/SCsub @@ -105,7 +105,7 @@ elif env["builtin_vulkan"]: else: # Always build VMA. thirdparty_dir = "#thirdparty/vulkan" - env.Prepend(CPPPATH=[thirdparty_dir]) + env.Prepend(CPPPATH=[thirdparty_dir, thirdparty_dir + "/include"]) # Build Vulkan loader library env_thirdparty = env.Clone() diff --git a/platform/osx/detect.py b/platform/osx/detect.py index 317e79d0ead..2393f2ea105 100644 --- a/platform/osx/detect.py +++ b/platform/osx/detect.py @@ -24,6 +24,7 @@ def get_opts(): return [ ("osxcross_sdk", "OSXCross SDK version", "darwin16"), ("MACOS_SDK_PATH", "Path to the macOS SDK", ""), + ("VULKAN_SDK_PATH", "Path to the Vulkan SDK", ""), BoolVariable( "use_static_mvk", "Link MoltenVK statically as Level-0 driver (better portability) or use Vulkan ICD loader (enables" @@ -190,7 +191,7 @@ def configure(env): env.Append(CPPDEFINES=["VULKAN_ENABLED"]) env.Append(LINKFLAGS=["-framework", "Metal", "-framework", "QuartzCore", "-framework", "IOSurface"]) if env["use_static_mvk"]: - env.Append(LINKFLAGS=["-framework", "MoltenVK"]) + env.Append(LINKFLAGS=["-L$VULKAN_SDK_PATH/MoltenVK/MoltenVK.xcframework/macos-arm64_x86_64/", "-lMoltenVK"]) env["builtin_vulkan"] = False elif not env["builtin_vulkan"]: env.Append(LIBS=["vulkan"])