|
1 | | -# Zig-ZFP: A Zig Build Process for the ZFP Compression Library |
2 | | -This is intended to be a simple build wrapper around the [ZFP C compression library](https://github.com/LLNL/zfp) for Zig. |
| 1 | +# zfp-zig: zfp packaged for the Zig programming language |
| 2 | +This is the [ZFP C compression library](https://github.com/LLNL/zfp) for the [Zig](https://ziglang.org/) programming language. |
| 3 | + |
| 4 | +# How do I include it in my Zig program? |
| 5 | +If you are starting a new package: |
| 6 | +```bash |
| 7 | + |
| 8 | +mkdir my_project; cd my_project |
| 9 | +zig init |
| 10 | +## add the package to 'build.zig.zon' |
| 11 | +zig fetch --save=zfp git+https://github.com/keltonhalbert/zfp.git |
| 12 | +``` |
| 13 | +This will add the zig C library as a dependency to your project. |
| 14 | +Next, if you are linking it to a library or executable, add the following to **build.zig**: |
| 15 | +```Zig |
| 16 | +pub fn build(b: *std.Build) !void { |
| 17 | + const target = b.standardTargetOptions(.{}); |
| 18 | +
|
| 19 | + const optimize = b.standardOptimizeOption(.{}); |
| 20 | +
|
| 21 | + const zfp_dep = b.dependency("zfp", .{ |
| 22 | + .target = target, |
| 23 | + .optimize = optimize, |
| 24 | + }); |
| 25 | +
|
| 26 | + // if you are linking it to a library... |
| 27 | + const lib_mod = b.createModule(.{ |
| 28 | + .root_source_file = b.path("src/root.zig"), |
| 29 | + .target = target, |
| 30 | + .optimize = optimize, |
| 31 | + }); |
| 32 | +
|
| 33 | + lib_mod.linkLibrary(zfp_dep.artifact("zfp")); |
| 34 | + |
| 35 | + // or, if you are linking it to an executable... |
| 36 | + const exe_mod = b.createModule(.{ |
| 37 | + .root_source_file = b.path("src/main.zig"), |
| 38 | + .target = target, |
| 39 | + .optimize = optimize, |
| 40 | + }); |
| 41 | +
|
| 42 | + exe_mod.linkLibrary(zfp_dep.artifact("zfp")); |
| 43 | +} |
| 44 | +``` |
| 45 | +# Requirements |
| 46 | +The target version of Zig is ```0.14```. It may work with earlier versions, but has not been tested. |
0 commit comments