diff --git a/libs/freetype/README.md b/libs/freetype/README.md index 9a794849..2ed89e79 100644 --- a/libs/freetype/README.md +++ b/libs/freetype/README.md @@ -30,6 +30,9 @@ pub fn build(b: *Builder) void { ... exe.addPackage(freetype.pkg); freetype.link(b, exe, .{}); + + // use this option if you are including zlib separately + //freetype.link(b, exe, .{ .freetype = .{ .use_system_zlib = true } }); } ``` diff --git a/libs/freetype/build.zig b/libs/freetype/build.zig index 9ab258a4..c201e124 100644 --- a/libs/freetype/build.zig +++ b/libs/freetype/build.zig @@ -30,6 +30,7 @@ pub const FreetypeOptions = struct { config_path: ?[]const u8 = null, install_libs: bool = false, brotli: bool = false, + use_system_zlib: bool = false, }; pub const HarfbuzzOptions = struct { @@ -131,6 +132,9 @@ pub fn buildFreetype(b: *Builder, mode: std.builtin.Mode, target: std.zig.CrossT const lib = b.addStaticLibrary("freetype", null); lib.defineCMacro("FT2_BUILD_LIBRARY", "1"); + if (options.use_system_zlib) { + lib.defineCMacro("FT_CONFIG_OPTION_SYSTEM_ZLIB", "1"); + } lib.setBuildMode(mode); lib.setTarget(target); lib.linkLibC();