-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.zig
More file actions
50 lines (41 loc) · 1.48 KB
/
build.zig
File metadata and controls
50 lines (41 loc) · 1.48 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
46
47
48
49
50
const std = @import("std");
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const include = b.path("include");
const module = b.createModule(.{
.target = target,
.optimize = optimize,
.link_libcpp = true,
});
module.addIncludePath(include);
module.addCSourceFiles(.{
.root = b.path("src"),
.files = &.{"source.cpp"},
.flags = &CXXFLAGS,
});
const lib = b.addLibrary(.{ .name = "demo", .root_module = module });
lib.installHeadersDirectory(include, "demo", .{ .include_extensions = &.{".hpp"} });
b.installArtifact(lib);
{ // Test
const test_step = b.step("test", "Run tests");
const catch2_dep = b.dependency("catch2", .{ .target = target, .optimize = optimize });
const test_mod = b.createModule(.{ .target = target, .optimize = optimize });
const test_exe = b.addExecutable(.{ .name = "test_demo", .root_module = test_mod });
test_mod.addCSourceFiles(.{
.root = b.path("test"),
.files = &.{"test.cpp"},
.flags = &CXXFLAGS,
});
test_mod.linkLibrary(lib);
test_mod.linkLibrary(catch2_dep.artifact("Catch2"));
test_mod.linkLibrary(catch2_dep.artifact("Catch2WithMain"));
test_step.dependOn(&b.addRunArtifact(test_exe).step);
}
}
const CXXFLAGS = .{
"--std=c++23",
"-Wall",
"-Wextra",
"-Werror",
};