From 3ffc6d1fc86937dde3e27c31c687b62be8cbf689 Mon Sep 17 00:00:00 2001 From: Samuel Evans-Powell Date: Thu, 7 Dec 2023 11:38:53 +0800 Subject: [PATCH] glfw: Fix MinGW Build - Adjust build inputs and CMake flags to support cross-compilation of GLFW. Co-authored-by: Weijia Wang <9713184+wegank@users.noreply.github.com> --- pkgs/development/libraries/glfw/3.x.nix | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pkgs/development/libraries/glfw/3.x.nix b/pkgs/development/libraries/glfw/3.x.nix index 15c5e7d9ca58..4e01ca5c2b6e 100644 --- a/pkgs/development/libraries/glfw/3.x.nix +++ b/pkgs/development/libraries/glfw/3.x.nix @@ -19,21 +19,22 @@ stdenv.mkDerivation rec { # Fix linkage issues on X11 (https://github.com/NixOS/nixpkgs/issues/142583) patches = lib.optional (!waylandSupport) ./x11.patch; - propagatedBuildInputs = [ (if stdenv.isDarwin then OpenGL else libGL) ]; + propagatedBuildInputs = + lib.optionals stdenv.isDarwin [ OpenGL ] + ++ lib.optionals stdenv.isLinux [ libGL ]; nativeBuildInputs = [ cmake ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames ++ lib.optional waylandSupport extra-cmake-modules; buildInputs = - if waylandSupport - then [ wayland wayland-protocols libxkbcommon ] - else [ libX11 libXrandr libXinerama libXcursor libXi libXext ] - ++ lib.optionals stdenv.isDarwin [ Carbon Cocoa Kernel ]; + lib.optionals stdenv.isDarwin [ Carbon Cocoa Kernel ] + ++ lib.optionals (stdenv.isLinux && waylandSupport) [ wayland wayland-protocols libxkbcommon ] + ++ lib.optionals (stdenv.isLinux && !waylandSupport) [ libX11 libXrandr libXinerama libXcursor libXi libXext ]; cmakeFlags = [ "-DBUILD_SHARED_LIBS=ON" - ] ++ lib.optionals (!stdenv.isDarwin) [ + ] ++ lib.optionals (!stdenv.isDarwin && !stdenv.hostPlatform.isWindows) [ "-DCMAKE_C_FLAGS=-D_GLFW_GLX_LIBRARY='\"${lib.getLib libGL}/lib/libGL.so.1\"'" ] ++ lib.optionals waylandSupport [ "-DGLFW_USE_WAYLAND=ON" @@ -50,6 +51,6 @@ stdenv.mkDerivation rec { homepage = "https://www.glfw.org/"; license = licenses.zlib; maintainers = with maintainers; [ marcweber twey ]; - platforms = platforms.unix; + platforms = platforms.unix ++ platforms.windows; }; }