lol
at 24.11-pre 66 lines 2.3 kB view raw
1{ lib, stdenv, fetchurl, fetchpatch, cmake, libGLU, libXmu, libXi, libXext 2, OpenGL 3, enableEGL ? false 4, testers 5}: 6 7stdenv.mkDerivation (finalAttrs: { 8 pname = "glew"; 9 version = "2.2.0"; 10 11 src = fetchurl { 12 url = "mirror://sourceforge/glew/${finalAttrs.pname}-${finalAttrs.version}.tgz"; 13 sha256 = "1qak8f7g1iswgswrgkzc7idk7jmqgwrs58fhg2ai007v7j4q5z6l"; 14 }; 15 16 outputs = [ "bin" "out" "dev" ]; 17 18 patches = [ 19 # https://github.com/nigels-com/glew/pull/342 20 (fetchpatch { 21 url = "https://github.com/nigels-com/glew/commit/966e53fa153175864e151ec8a8e11f688c3e752d.diff"; 22 sha256 = "sha256-xsSwdAbdWZA4KVoQhaLlkYvO711i3QlHGtv6v1Omkhw="; 23 }) 24 ]; 25 26 nativeBuildInputs = [ cmake ]; 27 buildInputs = lib.optionals (!stdenv.isDarwin) [ libXmu libXi libXext ]; 28 propagatedBuildInputs = if stdenv.isDarwin then [ OpenGL ] else [ libGLU ]; # GL/glew.h includes GL/glu.h 29 30 cmakeDir = "cmake"; 31 cmakeFlags = [ 32 "-DBUILD_SHARED_LIBS=ON" 33 ] ++ lib.optional enableEGL "-DGLEW_EGL=ON"; 34 35 postInstall = '' 36 moveToOutput lib/cmake "''${!outputDev}" 37 moveToOutput lib/pkgconfig "''${!outputDev}" 38 39 cat >> "''${!outputDev}"/lib/cmake/glew/glew-config.cmake <<EOF 40 # nixpkg's workaround for a cmake bug 41 # https://discourse.cmake.org/t/the-findglew-cmake-module-does-not-set-glew-libraries-in-some-cases/989/3 42 set(GLEW_VERSION "$version") 43 set(GLEW_LIBRARIES GLEW::glew\''${_glew_target_postfix}) 44 get_target_property(GLEW_INCLUDE_DIRS GLEW::glew\''${_glew_target_postfix} INTERFACE_INCLUDE_DIRECTORIES) 45 set_target_properties(GLEW::GLEW\''${_glew_target_postfix} PROPERTIES 46 IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE "" 47 IMPORTED_IMPLIB_RELEASE "GLEW" 48 IMPORTED_IMPLIB_DEBUG "GLEW" 49 ) 50 EOF 51 ''; 52 53 passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; 54 55 meta = with lib; { 56 description = "An OpenGL extension loading library for C/C++"; 57 homepage = "https://glew.sourceforge.net/"; 58 license = with licenses; [ /* modified bsd */ free mit gpl2Only ]; # For full details, see https://github.com/nigels-com/glew#copyright-and-licensing 59 pkgConfigModules = [ "glew" ]; 60 platforms = with platforms; 61 if enableEGL then 62 subtractLists darwin mesaPlatforms 63 else 64 mesaPlatforms; 65 }; 66})