googletest packaged with Zig
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-06-19 17:42:43 +02:00
.github/workflows reduce size of CI matrix 2026-06-19 17:42:43 +02:00
.gitignore Update to Zig 0.16.0 (#7) 2026-06-19 17:40:08 +02:00
build.zig Update to Zig 0.16.0 (#7) 2026-06-19 17:40:08 +02:00
build.zig.zon Update to Zig 0.16.0 (#7) 2026-06-19 17:40:08 +02:00
LICENSE init 2024-09-21 22:50:28 +02:00
README.md Build with Zig 0.15.2 and bump googletest (#5) 2026-02-12 11:25:53 -08:00

googletest

This is googletest, packaged for Zig.

How to use it

First, update your build.zig.zon:

zig fetch --save git+https://github.com/allyourcodebase/googletest

Next, in build.zig, declare the dependency and link your test with the static libraries:

const googletest_dep = b.dependency("googletest", .{
    .target = target,
    .optimize = optimize,
});

const tests_exe = b.addExecutable(.{
    .name = "tests",
    .root_module = b.createModule(.{ .target = target, .optimize = optimize }),
});
tests_exe.addCSourceFiles(.{ .files = &.{"src/tests.cpp"} }); // your test files
tests_exe.linkLibrary(googletest_dep.artifact("gtest"));
// Unless you define your own entry point, you need `gtest_main` too.
tests_exe.linkLibrary(googletest_dep.artifact("gtest_main"));