zig icon indicating copy to clipboard operation
zig copied to clipboard

zig build: respect PKG_CONFIG environment variable

Open BratishkaErik opened this issue 9 months ago • 5 comments

PKG_CONFIG environment variable is used to override path to pkg-config executable, for example when it's name is prepended by target triple for cross-compilation purposes:

PKG_CONFIG=/usr/bin/aarch64-unknown-linux-gnu-pkgconf zig build

BratishkaErik avatar May 08 '24 19:05 BratishkaErik

standard practice here is to check the PKG_CONFIG env var

nektro avatar May 08 '24 20:05 nektro

standard practice here is to check the PKG_CONFIG env var

I know, it was intentionally omitted. I think it will be easier to merge without it, since there are less lines added and less ehh controversial points (IIRC core team wants to avoid this kind of environment variables, f.e. https://github.com/ziglang/zig/issues/17585 and https://github.com/ziglang/zig/issues/10754#issuecomment-1519151708), don't want to convince them, just easy merge.

BratishkaErik avatar May 08 '24 21:05 BratishkaErik

Fixed merge conflict.

BratishkaErik avatar May 09 '24 09:05 BratishkaErik

I don't see how those linked issues are relevant. If PKG_CONFIG environment variable is a standard practice then it's desirable to use as the default. The purpose of the pkg-config integration is to integrate with the system. Respecting a standard environment variable would make the system integration more complete.

It's even better, will do :)

BratishkaErik avatar May 12 '24 14:05 BratishkaErik

you can use below code in the build.zig to achieve the same effect.

b.graph.env_map.put("PKG_CONFIG_PATH", "XXXX") catch unreachable;

xnhp0320 avatar May 17 '24 13:05 xnhp0320

Thanks!

BratishkaErik avatar Jul 24 '24 05:07 BratishkaErik