diff --git a/glfw/build.zig b/glfw/build.zig index 780bbb6d..85fa4ff3 100644 --- a/glfw/build.zig +++ b/glfw/build.zig @@ -215,6 +215,14 @@ fn linkGLFWDependencies(b: *Builder, step: *std.build.LibExeObjStep, options: Op if (options.opengl) { step.linkFramework("OpenGL"); } + + // These are dependencies of the above frameworks, but are not properly picked by zld + // when cross-compiling Windows/Linux -> MacOS unless linked explicitly here. + step.linkFramework("CoreGraphics"); + step.linkFramework("CoreServices"); + step.linkFramework("AppKit"); + step.linkFramework("Foundation"); + step.linkSystemLibrary("objc"); }, else => { // Assume Linux-like @@ -241,17 +249,16 @@ fn linkGLFWDependencies(b: *Builder, step: *std.build.LibExeObjStep, options: Op } fn includeSdkMacOS(b: *Builder, step: *std.build.LibExeObjStep) void { - step.addFrameworkDir("/System/Library/Frameworks"); - step.addSystemIncludeDir("/usr/include"); - step.addLibPath("/usr/lib"); - - // Add the SDK as a sysroot. Using this instead of, say, absolute framework/include/lib paths - // to the SDK without a sysroot ensures that we use the same libraries/frameworks/headers on - // Mac hosts and non-Mac hosts. const sdk_root_dir = getSdkRoot(b.allocator, "sdk-macos-11.3") catch unreachable; - defer b.allocator.free(sdk_root_dir); - var sdk_sysroot = std.fs.path.join(b.allocator, &.{ sdk_root_dir, "root/" }) catch unreachable; - b.sysroot = sdk_sysroot; + + var sdk_framework_dir = std.fs.path.join(b.allocator, &.{ sdk_root_dir, "root/System/Library/Frameworks" }) catch unreachable; + step.addFrameworkDir(sdk_framework_dir); + + var sdk_include_dir = std.fs.path.join(b.allocator, &.{ sdk_root_dir, "root/usr/include" }) catch unreachable; + step.addSystemIncludeDir(sdk_include_dir); + + var sdk_lib_dir = std.fs.path.join(b.allocator, &.{ sdk_root_dir, "root/usr/lib" }) catch unreachable; + step.addLibPath(sdk_lib_dir); } fn includeSdkLinuxX8664(b: *Builder, step: *std.build.LibExeObjStep) void {