build: never use pkg-config to link system libraries (#217)
Every library we want to link against is either provided by the Zig toolchain or part of our SDK. Therefore, using pkg-config to link against libraries on the host system is never what we intend. To fix this, use linkSystemLibraryName() everywhere instead of linkSystemLibrary() as the latter integrates with pkg-config while the former just passes -lfoo to the zig compiler. In combination with Zig commit 38d6e1d8a8 fixing an std.build bug, this change fixes the linking of the necessary X11 libraries on my x86_64 glibc based Void Linux system.
This commit is contained in:
parent
f2ce208aa1
commit
02e357ab44
2 changed files with 25 additions and 25 deletions
|
|
@ -115,14 +115,14 @@ fn linkGLFWDependencies(b: *Builder, step: *std.build.LibExeObjStep, options: Op
|
|||
const target = (std.zig.system.NativeTargetInfo.detect(b.allocator, step.target) catch unreachable).target;
|
||||
switch (target.os.tag) {
|
||||
.windows => {
|
||||
step.linkSystemLibrary("gdi32");
|
||||
step.linkSystemLibrary("user32");
|
||||
step.linkSystemLibrary("shell32");
|
||||
step.linkSystemLibraryName("gdi32");
|
||||
step.linkSystemLibraryName("user32");
|
||||
step.linkSystemLibraryName("shell32");
|
||||
if (options.opengl) {
|
||||
step.linkSystemLibrary("opengl32");
|
||||
step.linkSystemLibraryName("opengl32");
|
||||
}
|
||||
if (options.gles) {
|
||||
step.linkSystemLibrary("GLESv3");
|
||||
step.linkSystemLibraryName("GLESv3");
|
||||
}
|
||||
},
|
||||
.macos => {
|
||||
|
|
@ -134,7 +134,7 @@ fn linkGLFWDependencies(b: *Builder, step: *std.build.LibExeObjStep, options: Op
|
|||
if (options.opengl) {
|
||||
step.linkFramework("OpenGL");
|
||||
}
|
||||
step.linkSystemLibrary("objc");
|
||||
step.linkSystemLibraryName("objc");
|
||||
step.linkFramework("AppKit");
|
||||
step.linkFramework("CoreServices");
|
||||
step.linkFramework("CoreGraphics");
|
||||
|
|
@ -144,20 +144,20 @@ fn linkGLFWDependencies(b: *Builder, step: *std.build.LibExeObjStep, options: Op
|
|||
// Assume Linux-like
|
||||
switch (options.linux_window_manager) {
|
||||
.X11 => {
|
||||
step.linkSystemLibrary("X11");
|
||||
step.linkSystemLibrary("xcb");
|
||||
step.linkSystemLibrary("Xau");
|
||||
step.linkSystemLibrary("Xdmcp");
|
||||
step.linkSystemLibraryName("X11");
|
||||
step.linkSystemLibraryName("xcb");
|
||||
step.linkSystemLibraryName("Xau");
|
||||
step.linkSystemLibraryName("Xdmcp");
|
||||
},
|
||||
.Wayland => step.linkSystemLibrary("wayland-client"),
|
||||
.Wayland => step.linkSystemLibraryName("wayland-client"),
|
||||
}
|
||||
// Note: no need to link against vulkan, GLFW finds it dynamically at runtime.
|
||||
// https://www.glfw.org/docs/3.3/vulkan_guide.html#vulkan_loader
|
||||
if (options.opengl) {
|
||||
step.linkSystemLibrary("GL");
|
||||
step.linkSystemLibraryName("GL");
|
||||
}
|
||||
if (options.gles) {
|
||||
step.linkSystemLibrary("GLESv3");
|
||||
step.linkSystemLibraryName("GLESv3");
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue