Skip to content

Commit 9b048bd

Browse files
committed
Release 3.12.0
1 parent 8d37929 commit 9b048bd

File tree

6 files changed

+100
-62
lines changed

6 files changed

+100
-62
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919

2020
runs-on: ${{ matrix.os }}
2121
steps:
22-
- uses: actions/checkout@v4
22+
- uses: actions/checkout@v6
2323
- uses: mlugg/setup-zig@v2
2424
with:
2525
version: ${{ matrix.zig-version }}
@@ -28,7 +28,7 @@ jobs:
2828
run: zig build --summary all
2929

3030
- name: Run tests
31-
run: zig build test --summary all
31+
run: zig build test --summary new
3232

3333
- name: Build & Run example tests
3434
run: cd example && zig build test --summary all

README.md

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@ Provides a package to be used by the zig package manager for C++ programs.
44

55
## Status
66

7-
| Refname | Catch2 version | Zig `0.15.x` | Zig `0.14.x` | Zig `0.13.x` | Zig `0.12.x` |
8-
|:----------|:---------------|:------------:|:------------:|:------------:|:------------:|
9-
| `3.11.0` | `v3.11.0` | ⚠️ ||||
10-
| `3.10.0` | `v3.10.0` | ⚠️ ||||
11-
| `3.9.1` | `v3.9.1` | ⚠️ ||||
12-
| `3.9.0` | `v3.9.0` | ⚠️ ||||
13-
| `3.8.1` | `v3.8.1` |||||
14-
| `3.8.0+1` | `v3.8.0` |||||
15-
| `3.8.0` | `v3.8.0` |||||
16-
| `3.7.1+1` | `v3.7.1` |||||
17-
18-
⚠️ means that that the package is compatible with `0.15` but that Catch2's own tests fail because of [a regression of LLVM 20](https://github.com/llvm/llvm-project/issues/140519).
7+
| Refname | Catch2 version | Zig `0.16.x` | Zig `0.15.x` | Zig `0.14.x` | Zig `0.13.x` | Zig `0.12.x` |
8+
|:----------|:---------------|:------------:|:------------:|:------------:|:------------:|:------------:|
9+
| `3.12.0` | `v3.12.0` ||||||
10+
| `3.11.0` | `v3.11.0` ||||||
11+
| `3.10.0` | `v3.10.0` ||||||
12+
| `3.9.1` | `v3.9.1` ||||||
13+
| `3.9.0` | `v3.9.0` ||||||
14+
| `3.8.1` | `v3.8.1` ||||||
15+
| `3.8.0+1` | `v3.8.0` ||||||
16+
| `3.8.0` | `v3.8.0` ||||||
17+
| `3.7.1+1` | `v3.7.1` ||||||
18+
19+
✔ means that that the package is compatible but that Catch2's own tests fail because of [a regression of LLVM 20](https://github.com/llvm/llvm-project/issues/140519).
1920
The error occurs when using `TEMPLATE_PRODUCT_TEST_CASE`: [Build failure with clang++ 20](https://github.com/catchorg/Catch2/issues/2991). If you don't use this macro you should be fine.
2021

2122
## Use
@@ -30,9 +31,20 @@ Then, in your `build.zig`:
3031
const catch2_dep = b.dependency("catch2", { .target = target, .optimize = optimize });
3132
const catch2_lib = catch2_dep.artifact("Catch2");
3233
const catch2_main = catch2_dep.artifact("Catch2WithMain");
34+
3335
// wherever needed:
3436
exe.linkLibrary(catch2_lib);
3537
exe.linkLibrary(catch2_main);
3638
```
3739

3840
A complete usage demonstration is provided in the [example](example) directory
41+
42+
## Options
43+
44+
```
45+
-Dadd-prefix=[bool] Prefix all macros with CATCH_
46+
-Dconsole-width=[int] Number of columns in the output: affects line wraps. (Defaults to 80)
47+
-Dfast-compile=[bool] Sacrifices some (rather minor) features for compilation speed
48+
-Ddisable=[bool] Disables assertions and test case registration
49+
-Ddefault-reporter=[string] Choose the reporter to use when it is not specified via the --reporter option. (Defaults to 'console')
50+
```

build.zig

Lines changed: 49 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
const std = @import("std");
22

3-
const version = .{ .major = 3, .minor = 10, .patch = 0 };
4-
53
pub fn build(b: *std.Build) !void {
64
const target = b.standardTargetOptions(.{});
75
const optimize = b.standardOptimizeOption(.{});
86

9-
const upstream = b.dependency("upstream", .{ .target = target, .optimize = optimize });
10-
117
const add_prefix = b.option(bool, "add-prefix", "Prefix all macros with CATCH_") orelse false;
128
const console_width = b.option(u32, "console-width", "Number of columns in the output: affects line wraps. (Defaults to 80)") orelse 80;
139
const fast_compile = b.option(bool, "fast-compile", "Sacrifices some (rather minor) features for compilation speed") orelse false;
1410
const disable = b.option(bool, "disable", "Disables assertions and test case registration") orelse false;
1511
const default_reporter = b.option([]const u8, "default-reporter", "Choose the reporter to use when it is not specified via the --reporter option. (Defaults to 'console')") orelse "console";
1612

13+
const upstream = b.dependency("upstream", .{});
14+
1715
const config = b.addConfigHeader(
1816
.{
1917
.style = .{ .cmake = upstream.path("src/catch2/catch_user_config.hpp.in") },
@@ -29,42 +27,68 @@ pub fn build(b: *std.Build) !void {
2927
},
3028
);
3129

32-
const catch2 = b.addLibrary(.{ .name = "Catch2", .root_module = b.createModule(.{ .target = target, .optimize = optimize }) });
33-
catch2.addCSourceFiles(.{
30+
const catch2 = b.addLibrary(.{
31+
.name = "Catch2",
32+
.root_module = b.createModule(.{
33+
.target = target,
34+
.optimize = optimize,
35+
.link_libcpp = true,
36+
}),
37+
});
38+
catch2.root_module.addCSourceFiles(.{
3439
.root = upstream.path("src/catch2"),
3540
.files = &source_files,
3641
.flags = &CXXFLAGS,
3742
});
3843
catch2.installConfigHeader(config);
39-
catch2.installHeadersDirectory(upstream.path("src"), "", .{ .include_extensions = &.{".hpp"} });
44+
catch2.installHeadersDirectory(upstream.path("src"), "", .{
45+
.include_extensions = &.{".hpp"},
46+
});
4047

41-
const with_main = b.addLibrary(.{ .name = "Catch2WithMain", .root_module = b.createModule(.{ .target = target, .optimize = optimize }) });
42-
with_main.addCSourceFiles(.{
43-
.root = upstream.path("src/catch2/internal"),
44-
.files = &.{"catch_main.cpp"},
48+
const with_main = b.addLibrary(.{
49+
.name = "Catch2WithMain",
50+
.root_module = b.createModule(.{
51+
.target = target,
52+
.optimize = optimize,
53+
.link_libcpp = true,
54+
}),
55+
});
56+
with_main.root_module.addCSourceFile(.{
57+
.file = upstream.path("src/catch2/internal/catch_main.cpp"),
4558
.flags = &CXXFLAGS,
4659
});
4760

48-
const test_step = b.step("test", "Run tests");
49-
const test_exe = b.addExecutable(.{ .name = "SelfTest", .root_module = b.createModule(.{ .target = target, .optimize = optimize }) });
50-
test_exe.addIncludePath(upstream.path("tests/SelfTest"));
51-
test_exe.addCSourceFiles(.{ .root = upstream.path("tests/SelfTest"), .files = &test_files, .flags = &CXXFLAGS });
52-
test_exe.linkLibCpp();
53-
const run_test = b.addRunArtifact(test_exe);
54-
test_step.dependOn(&run_test.step);
55-
56-
const libs = [_]*std.Build.Step.Compile{ catch2, with_main };
61+
const libs: []const *std.Build.Step.Compile = &.{ catch2, with_main };
5762
for (libs) |lib| {
58-
lib.linkLibCpp();
59-
lib.addIncludePath(upstream.path("src"));
60-
lib.addConfigHeader(config);
63+
lib.root_module.addIncludePath(upstream.path("src"));
64+
lib.root_module.addConfigHeader(config);
6165
b.installArtifact(lib);
62-
test_exe.linkLibrary(lib);
66+
}
67+
68+
{ // Testing
69+
const test_step = b.step("test", "Run tests");
70+
const test_exe = b.addExecutable(.{
71+
.name = "SelfTest",
72+
.root_module = b.createModule(.{
73+
.target = target,
74+
.optimize = optimize,
75+
.link_libcpp = true,
76+
}),
77+
});
78+
test_exe.root_module.addIncludePath(upstream.path("tests/SelfTest"));
79+
test_exe.root_module.addCSourceFiles(.{
80+
.root = upstream.path("tests/SelfTest"),
81+
.files = &test_files,
82+
.flags = &CXXFLAGS,
83+
});
84+
test_exe.root_module.linkLibrary(catch2);
85+
test_exe.root_module.linkLibrary(with_main);
86+
test_step.dependOn(&b.addRunArtifact(test_exe).step);
6387
}
6488
}
6589

6690
const CXXFLAGS = .{
67-
"--std=c++20",
91+
"--std=c++23",
6892
"-Wall",
6993
"-Wextra",
7094
"-Werror",

build.zig.zon

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
.{
22
.name = .catch2,
3-
.version = "3.10.0",
3+
.version = "3.12.0",
44
.fingerprint = 0x50cf7037cefab352,
55
.minimum_zig_version = "0.14.0",
66
.dependencies = .{
77
.upstream = .{
8-
.url = "git+https://github.com/catchorg/Catch2?ref=v3.11.0#b3fb4b9feafcd8d91c5cb510a4775143fdbef02f",
9-
.hash = "N-V-__8AAFP0hwD3L7c67NtknrtZSvg3K7yUFIhCsOxLmYAH",
8+
.url = "git+https://github.com/catchorg/Catch2?ref=v3.12.0#88abf9bf325c798c33f54f6b9220ef885b267f4f",
9+
.hash = "N-V-__8AAA1iiAB-7p1uHA2cu3mmSN2ncyyURBkin7xOz0-V",
1010
},
1111
},
1212
.paths = .{

example/build.zig

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,39 @@ pub fn build(b: *std.Build) !void {
66

77
const include = b.path("include");
88

9-
const lib = b.addLibrary(.{
10-
.name = "demo",
11-
.root_module = b.createModule(.{ .target = target, .optimize = optimize }),
9+
const module = b.createModule(.{
10+
.target = target,
11+
.optimize = optimize,
12+
.link_libcpp = true,
1213
});
13-
lib.addIncludePath(include);
14-
lib.addCSourceFiles(.{
14+
module.addIncludePath(include);
15+
module.addCSourceFiles(.{
1516
.root = b.path("src"),
1617
.files = &.{"source.cpp"},
1718
.flags = &CXXFLAGS,
1819
});
19-
lib.linkLibCpp();
20+
21+
const lib = b.addLibrary(.{ .name = "demo", .root_module = module });
2022
lib.installHeadersDirectory(include, "demo", .{ .include_extensions = &.{".hpp"} });
2123
b.installArtifact(lib);
2224

2325
{ // Test
2426
const test_step = b.step("test", "Run tests");
25-
const test_exe = b.addExecutable(.{
26-
.name = "test_demo",
27-
.root_module = b.createModule(.{ .target = target, .optimize = optimize }),
28-
});
29-
const run_test = b.addRunArtifact(test_exe);
3027

3128
const catch2_dep = b.dependency("catch2", .{ .target = target, .optimize = optimize });
32-
const catch2_lib = catch2_dep.artifact("Catch2");
33-
const catch2_main = catch2_dep.artifact("Catch2WithMain");
34-
35-
test_exe.addCSourceFiles(.{ .root = b.path("test"), .files = &.{"test.cpp"}, .flags = &CXXFLAGS });
36-
test_exe.linkLibrary(lib);
37-
test_exe.linkLibrary(catch2_lib);
38-
test_exe.linkLibrary(catch2_main);
39-
test_step.dependOn(&run_test.step);
29+
30+
const test_mod = b.createModule(.{ .target = target, .optimize = optimize });
31+
const test_exe = b.addExecutable(.{ .name = "test_demo", .root_module = test_mod });
32+
33+
test_mod.addCSourceFiles(.{
34+
.root = b.path("test"),
35+
.files = &.{"test.cpp"},
36+
.flags = &CXXFLAGS,
37+
});
38+
test_mod.linkLibrary(lib);
39+
test_mod.linkLibrary(catch2_dep.artifact("Catch2"));
40+
test_mod.linkLibrary(catch2_dep.artifact("Catch2WithMain"));
41+
test_step.dependOn(&b.addRunArtifact(test_exe).step);
4042
}
4143
}
4244

example/build.zig.zon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.{
22
.name = .cath2UsageDemo,
3-
.version = "1.0.1",
3+
.version = "1.0.2",
44
.minimum_zig_version = "0.14.0",
55
.fingerprint = 0x77f3f25b1734ef7b,
66

0 commit comments

Comments
 (0)