allyourcodebase/fmt-zig
{fmt} C++ library uses build.zig
Using build.zig
integration for the {fmt} library - a modern formatting library providing a fast and safe alternative to C stdio and C++ iostreams.
Key features of {fmt}:
Make directory and init
$ zig init
## add in 'build.zig.zon' fmt-zig package
$ zig fetch --save=fmt git+https://github.com/allyourcodebase/fmt-zig
Add in build.zig
const std = @import("std");
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const fmt_dep = b.dependency("fmt", .{
.target = target,
.optimize = optimize,
});
const fmt_artifact = fmt_dep.artifact("fmt");
for(fmt_artifact.root_module.include_dirs.items) |include_dir| {
try exe.root_module.include_dirs.append(b.allocator, include_dir);
}
exe.linkLibrary(fmt_artifact);
}