Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prefix path for native dependency #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading