glfw3: general improvements (#358007)
This commit is contained in:
commit
9ef8694ce2
@ -1,24 +1,25 @@
|
||||
{ stdenv
|
||||
, lib
|
||||
, fetchFromGitHub
|
||||
, cmake
|
||||
, pkg-config
|
||||
, libGL
|
||||
, vulkan-loader
|
||||
, libXrandr
|
||||
, libXinerama
|
||||
, libXcursor
|
||||
, libX11
|
||||
, libXi
|
||||
, libXext
|
||||
, darwin
|
||||
, fixDarwinDylibNames
|
||||
, wayland
|
||||
, wayland-scanner
|
||||
, wayland-protocols
|
||||
, libxkbcommon
|
||||
, libdecor
|
||||
, withMinecraftPatch ? false
|
||||
{
|
||||
stdenv,
|
||||
lib,
|
||||
fetchFromGitHub,
|
||||
cmake,
|
||||
pkg-config,
|
||||
libGL,
|
||||
vulkan-loader,
|
||||
libXrandr,
|
||||
libXinerama,
|
||||
libXcursor,
|
||||
libX11,
|
||||
libXi,
|
||||
libXext,
|
||||
libXxf86vm,
|
||||
fixDarwinDylibNames,
|
||||
wayland,
|
||||
wayland-scanner,
|
||||
wayland-protocols,
|
||||
libxkbcommon,
|
||||
libdecor,
|
||||
withMinecraftPatch ? false,
|
||||
}:
|
||||
let
|
||||
version = "3.4";
|
||||
@ -35,59 +36,75 @@ stdenv.mkDerivation {
|
||||
};
|
||||
|
||||
# Fix linkage issues on X11 (https://github.com/NixOS/nixpkgs/issues/142583)
|
||||
patches = [
|
||||
./x11.patch
|
||||
] ++ lib.optionals withMinecraftPatch [
|
||||
./0009-Defer-setting-cursor-position-until-the-cursor-is-lo.patch
|
||||
];
|
||||
patches =
|
||||
[
|
||||
./x11.patch
|
||||
]
|
||||
++ lib.optionals withMinecraftPatch [
|
||||
./0009-Defer-setting-cursor-position-until-the-cursor-is-lo.patch
|
||||
];
|
||||
|
||||
propagatedBuildInputs = lib.optionals (!stdenv.hostPlatform.isWindows) [ libGL ];
|
||||
|
||||
nativeBuildInputs = [ cmake pkg-config ]
|
||||
nativeBuildInputs =
|
||||
[
|
||||
cmake
|
||||
pkg-config
|
||||
]
|
||||
++ lib.optionals stdenv.hostPlatform.isDarwin [ fixDarwinDylibNames ]
|
||||
++ lib.optionals stdenv.hostPlatform.isLinux [ wayland-scanner ];
|
||||
|
||||
buildInputs =
|
||||
lib.optionals stdenv.hostPlatform.isDarwin (with darwin.apple_sdk.frameworks; [ Carbon Cocoa Kernel ])
|
||||
++ lib.optionals stdenv.hostPlatform.isLinux [
|
||||
wayland
|
||||
wayland-protocols
|
||||
libxkbcommon
|
||||
libX11
|
||||
libXrandr
|
||||
libXinerama
|
||||
libXcursor
|
||||
libXi
|
||||
libXext
|
||||
];
|
||||
|
||||
cmakeFlags = [
|
||||
"-DBUILD_SHARED_LIBS=ON"
|
||||
] ++ lib.optionals (!stdenv.hostPlatform.isDarwin && !stdenv.hostPlatform.isWindows) [
|
||||
"-DCMAKE_C_FLAGS=-D_GLFW_GLX_LIBRARY='\"${lib.getLib libGL}/lib/libGL.so.1\"'"
|
||||
"-DCMAKE_C_FLAGS=-D_GLFW_EGL_LIBRARY='\"${lib.getLib libGL}/lib/libEGL.so.1\"'"
|
||||
"-DCMAKE_C_FLAGS=-D_GLFW_VULKAN_LIBRARY='\"${lib.getLib vulkan-loader}/lib/libvulkan.so.1\"'"
|
||||
buildInputs = lib.optionals stdenv.hostPlatform.isLinux [
|
||||
wayland
|
||||
wayland-protocols
|
||||
libxkbcommon
|
||||
libX11
|
||||
libXrandr
|
||||
libXinerama
|
||||
libXcursor
|
||||
libXi
|
||||
libXext
|
||||
libXxf86vm
|
||||
];
|
||||
|
||||
postPatch = lib.optionalString stdenv.hostPlatform.isLinux ''
|
||||
substituteInPlace src/wl_init.c \
|
||||
--replace-fail "libxkbcommon.so.0" "${lib.getLib libxkbcommon}/lib/libxkbcommon.so.0" \
|
||||
--replace-fail "libdecor-0.so.0" "${lib.getLib libdecor}/lib/libdecor-0.so.0" \
|
||||
--replace-fail "libwayland-client.so.0" "${lib.getLib wayland}/lib/libwayland-client.so.0" \
|
||||
--replace-fail "libwayland-cursor.so.0" "${lib.getLib wayland}/lib/libwayland-cursor.so.0" \
|
||||
--replace-fail "libwayland-egl.so.1" "${lib.getLib wayland}/lib/libwayland-egl.so.1"
|
||||
--replace-fail '"libdecor-0.so.0"' '"${lib.getLib libdecor}/lib/libdecor-0.so.0"' \
|
||||
--replace-fail '"libwayland-client.so.0"' '"${lib.getLib wayland}/lib/libwayland-client.so.0"' \
|
||||
--replace-fail '"libwayland-cursor.so.0"' '"${lib.getLib wayland}/lib/libwayland-cursor.so.0"' \
|
||||
--replace-fail '"libwayland-egl.so.1"' '"${lib.getLib wayland}/lib/libwayland-egl.so.1"' \
|
||||
--replace-fail '"libxkbcommon.so.0"' '"${lib.getLib libxkbcommon}/lib/libxkbcommon.so.0"'
|
||||
'';
|
||||
|
||||
# glfw may dlopen libwayland-client.so:
|
||||
postFixup = lib.optionalString stdenv.hostPlatform.isLinux ''
|
||||
patchelf ''${!outputLib}/lib/libglfw.so --add-rpath ${lib.getLib wayland}/lib
|
||||
'';
|
||||
cmakeFlags = [
|
||||
# Static linking isn't supported
|
||||
(lib.cmakeBool "BUILD_SHARED_LIBS" true)
|
||||
];
|
||||
|
||||
meta = with lib; {
|
||||
env = lib.optionalAttrs (!stdenv.hostPlatform.isDarwin && !stdenv.hostPlatform.isWindows) {
|
||||
NIX_CFLAGS_COMPILE = toString [
|
||||
"-D_GLFW_GLX_LIBRARY=\"${lib.getLib libGL}/lib/libGLX.so.0\""
|
||||
"-D_GLFW_EGL_LIBRARY=\"${lib.getLib libGL}/lib/libEGL.so.1\""
|
||||
"-D_GLFW_OPENGL_LIBRARY=\"${lib.getLib libGL}/lib/libGL.so.1\""
|
||||
"-D_GLFW_GLESV1_LIBRARY=\"${lib.getLib libGL}/lib/libGLESv1_CM.so.1\""
|
||||
"-D_GLFW_GLESV2_LIBRARY=\"${lib.getLib libGL}/lib/libGLESv2.so.2\""
|
||||
"-D_GLFW_VULKAN_LIBRARY=\"${lib.getLib vulkan-loader}/lib/libvulkan.so.1\""
|
||||
# This currently omits _GLFW_OSMESA_LIBRARY. Is it even used?
|
||||
];
|
||||
};
|
||||
|
||||
strictDeps = true;
|
||||
__structuredAttrs = true;
|
||||
|
||||
meta = {
|
||||
description = "Multi-platform library for creating OpenGL contexts and managing input, including keyboard, mouse, joystick and time";
|
||||
homepage = "https://www.glfw.org/";
|
||||
license = licenses.zlib;
|
||||
maintainers = with maintainers; [ marcweber Scrumplex twey ];
|
||||
platforms = platforms.unix ++ platforms.windows;
|
||||
license = lib.licenses.zlib;
|
||||
maintainers = with lib.maintainers; [
|
||||
marcweber
|
||||
Scrumplex
|
||||
twey
|
||||
];
|
||||
platforms = lib.platforms.unix ++ lib.platforms.windows;
|
||||
};
|
||||
}
|
||||
|
@ -2,17 +2,20 @@ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
|
||||
index a0be580e..ba143851 100644
|
||||
--- a/src/CMakeLists.txt
|
||||
+++ b/src/CMakeLists.txt
|
||||
@@ -219,6 +219,13 @@ if (GLFW_BUILD_X11)
|
||||
@@ -219,6 +219,16 @@ if (GLFW_BUILD_X11)
|
||||
if (NOT X11_Xshape_INCLUDE_PATH)
|
||||
message(FATAL_ERROR "X Shape headers not found; install libxext development package")
|
||||
endif()
|
||||
+
|
||||
+ target_link_libraries(glfw PRIVATE ${X11_Xrandr_LIB}
|
||||
+ ${X11_Xinerama_LIB}
|
||||
+ ${X11_X11_xcb_LIB}
|
||||
+ ${X11_Xrender_LIB}
|
||||
+ ${X11_Xkb_LIB}
|
||||
+ ${X11_Xcursor_LIB}
|
||||
+ ${X11_Xi_LIB}
|
||||
+ ${X11_Xshape_LIB})
|
||||
+ ${X11_Xxf86vm_LIB}
|
||||
+ ${X11_Xext_LIB})
|
||||
endif()
|
||||
|
||||
if (UNIX AND NOT APPLE)
|
||||
|
Loading…
Reference in New Issue
Block a user