Skip to content

Commit

Permalink
Add prefix path for native dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
ritalin committed Jun 17, 2024
1 parent 3de1afc commit 0041d67
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,29 @@ pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});

_ = b.addModule("zzmq", .{
const mod_zmq = b.addModule("zzmq", .{
.root_source_file = b.path("src/zzmq.zig"),
});

// `zmq_prefix` must specified the full-path
const zmq_prefix = b.option([]const u8, "zmq_prefix", "zmq installed path");

if (zmq_prefix) |p| {
mod_zmq.addIncludePath(.{ .cwd_relative = b.pathResolve(&[_][]const u8 { p, "zmq/include" }) } );
mod_zmq.addLibraryPath(.{ .cwd_relative = b.pathResolve(&[_][]const u8 { p, "zmq/lib" }) });
}

const lib_test = b.addTest(.{
.root_source_file = b.path("src/zzmq.zig"),
.target = target,
.optimize = optimize,
});

if (zmq_prefix) |p| {
lib_test.addIncludePath(.{ .cwd_relative = b.pathResolve(&[_][]const u8 { p, "zmq/include" }) } );
lib_test.addLibraryPath(.{ .cwd_relative = b.pathResolve(&[_][]const u8 { p, "zmq/lib" }) });
}

lib_test.linkSystemLibrary("zmq");
lib_test.linkLibC();

Expand Down

0 comments on commit 0041d67

Please sign in to comment.