Add the ability to override the libsodium install dirs

This commit is contained in:
Frank Denis 2025-01-16 12:55:52 +01:00
parent 101e90a668
commit 90d46db240

View file

@ -46,12 +46,21 @@ pub fn build(b: *std.Build) !void {
minisign.root_module.addCMacro("LIBZODIUM", "1");
minisign.linkLibrary(libzodium);
} else {
var override_pkgconfig = false;
if (std.posix.getenv("LIBSODIUM_INCLUDE_PATH")) |path| {
minisign.addSystemIncludePath(.{ .cwd_relative = path });
override_pkgconfig = true;
}
if (std.posix.getenv("LIBSODIUM_LIB_PATH")) |path| {
minisign.addLibraryPath(.{ .cwd_relative = path });
override_pkgconfig = true;
}
minisign.addLibraryPath(.{ .cwd_relative = "/opt/homebrew/lib" });
minisign.addLibraryPath(.{ .cwd_relative = "/usr/local/lib" });
minisign.root_module.linkSystemLibrary(
"sodium",
.{
.use_pkg_config = .yes,
.use_pkg_config = if (override_pkgconfig) .no else .yes,
.preferred_link_mode = if (use_static_linking) .static else .dynamic,
},
);