Catch 2 ported to the zig build system
  • Zig 93.3%
  • Shell 3.4%
  • C++ 3.3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Antoine Gagniere 4db68eb7fd Release 3.16.0
2026-08-29 22:19:10 +02:00
.github/workflows Release 3.16.0 2026-08-29 22:19:10 +02:00
example Release 3.12.0 2025-12-29 12:23:22 +01:00
.gitignore Generate file lists with a zig script 2026-04-18 14:38:31 +02:00
build.zig Generate file lists with a zig script 2026-04-18 14:38:31 +02:00
build.zig.zon Release 3.16.0 2026-08-29 22:19:10 +02:00
generate.zig Generate file lists with a zig script 2026-04-18 14:38:31 +02:00
generated.zig Release 3.16.0 2026-08-29 22:19:10 +02:00
LICENSE Initial commit: Build the libs 2024-09-18 22:10:25 +02:00
README.md Release 3.16.0 2026-08-29 22:19:10 +02:00
UPDATE.md Provide a complete update script 2026-04-18 15:24:28 +02:00
update.sh Provide a complete update script 2026-04-18 15:24:28 +02:00

build.zig for Catch2

Provides a package to be used by the zig package manager for C++ programs.

Status

Refname Catch2 version Zig 0.17-dev Zig 0.16.x Zig 0.15.x Zig 0.14.x Zig 0.13.x Zig 0.12.x
3.16.0 v3.16.0 ✅ ✅ ✅ ✅ ❌ ❌
3.8.0 v3.8.0 ❌ ❌ ❌ ❌ ✅ ✅

Use

Add the dependency in your build.zig.zon by running the following command:

zig fetch --save git+https://github.com/allyourcodebase/catch2#master

Then, in your build.zig:

const catch2_dep = b.dependency("catch2", { .target = target, .optimize = optimize });
const catch2_lib = catch2_dep.artifact("Catch2");
const catch2_main = catch2_dep.artifact("Catch2WithMain");

// wherever needed:
exe.linkLibrary(catch2_lib);
exe.linkLibrary(catch2_main);

A complete usage demonstration is provided in the example directory

Options

  -Dadd-prefix=[bool]          Prefix all macros with CATCH_
  -Dconsole-width=[int]        Number of columns in the output: affects line wraps. (Defaults to 80)
  -Dfast-compile=[bool]        Sacrifices some (rather minor) features for compilation speed
  -Ddisable=[bool]             Disables assertions and test case registration
  -Ddefault-reporter=[string]  Choose the reporter to use when it is not specified via the --reporter option. (Defaults to 'console')