add OS dependent library switch

It fixes build errors where "/opt/homebrew/lib" can not be found on Linux systems.
This commit is contained in:
Nicolas Schuler 2025-01-18 11:49:35 +01:00 committed by GitHub
parent 29a07eade0
commit 0824d30ddb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4,6 +4,7 @@ const std = @import("std");
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const native_os = @import("builtin").os.tag;
const use_libzodium = b.option(bool, "without-libsodium", "Use the zig standard library instead of libsodium") orelse false;
const use_static_linking = b.option(bool, "static", "Statically link the binary") orelse false;
@ -55,8 +56,11 @@ pub fn build(b: *std.Build) !void {
minisign.addLibraryPath(.{ .cwd_relative = path });
override_pkgconfig = true;
}
minisign.addLibraryPath(.{ .cwd_relative = "/opt/homebrew/lib" });
minisign.addLibraryPath(.{ .cwd_relative = "/usr/local/lib" });
switch (native_os) {
.linux => minisign.addLibraryPath(.{ .cwd_relative = "/usr/local/lib" }),
.macos => minisign.addLibraryPath(.{ .cwd_relative = "/opt/homebrew/lib" }),
else => {},
}
minisign.root_module.linkSystemLibrary(
"sodium",
.{