-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
45 lines (37 loc) · 1.43 KB
/
build.zig
File metadata and controls
45 lines (37 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const std = @import("std");
pub fn build(b: *std.Build) !void {
const optimize = b.standardOptimizeOption(.{});
const target = b.standardTargetOptions(.{});
const lib_nlopt_dep = b.dependency("lib_znlopt_mit", .{
.target = target,
.optimize = optimize,
});
const lib_nlopt_module = lib_nlopt_dep.module("lib_znlopt_mit");
// Create the znlopt wrapper module
const znlopt_mit_module = b.createModule(.{
.root_source_file = b.path("src/znlopt.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "lib_nlopt", .module = lib_nlopt_module },
},
});
// Export the znlopt module so other packages can import it
b.modules.put("znlopt-mit", znlopt_mit_module) catch @panic("failed to register znlopt module");
// --- Build an example executable ---
const example_exe = b.addExecutable(.{
.name = "znlopt_example",
.root_module = b.createModule(.{
.root_source_file = b.path("src/example.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "znlopt-mit", .module = znlopt_mit_module },
},
}),
});
b.installArtifact(example_exe);
const run_example_step = b.addRunArtifact(example_exe);
const run_step = b.step("run", "Run the nlopt example");
run_step.dependOn(&run_example_step.step);
}