Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 fetchpatch, 6 cmake, 7 libGLU, 8 libXmu, 9 libXi, 10 libXext, 11 enableEGL ? (!stdenv.hostPlatform.isDarwin), 12 testers, 13 mesa, 14}: 15 16stdenv.mkDerivation (finalAttrs: { 17 pname = "glew"; 18 version = "2.2.0"; 19 20 src = fetchurl { 21 url = "mirror://sourceforge/glew/glew-${finalAttrs.version}.tgz"; 22 sha256 = "1qak8f7g1iswgswrgkzc7idk7jmqgwrs58fhg2ai007v7j4q5z6l"; 23 }; 24 25 outputs = [ 26 "bin" 27 "out" 28 "dev" 29 ]; 30 31 patches = [ 32 # https://github.com/nigels-com/glew/pull/342 33 (fetchpatch { 34 url = "https://github.com/nigels-com/glew/commit/966e53fa153175864e151ec8a8e11f688c3e752d.diff"; 35 hash = "sha256-xsSwdAbdWZA4KVoQhaLlkYvO711i3QlHGtv6v1Omkhw="; 36 }) 37 38 # don't make EGL support disable GLX, use the same patch as ArchLinux 39 # https://gitlab.archlinux.org/archlinux/packaging/packages/glew/-/blob/ca08ff5d4cd3548a593eb1118d0a84b0c3670349/egl+glx.patch 40 (fetchpatch { 41 url = "https://gitlab.archlinux.org/archlinux/packaging/packages/glew/-/raw/ca08ff5d4cd3548a593eb1118d0a84b0c3670349/egl+glx.patch?inline=false"; 42 hash = "sha256-IG3FPhhaor1kshEH3Kr8yzIHqBhczRwCqH7ZeDwlzGE="; 43 }) 44 ]; 45 46 nativeBuildInputs = [ cmake ]; 47 buildInputs = lib.optionals (!stdenv.hostPlatform.isDarwin) [ 48 libXmu 49 libXi 50 libXext 51 ]; 52 propagatedBuildInputs = lib.optionals (!stdenv.hostPlatform.isDarwin) [ libGLU ]; # GL/glew.h includes GL/glu.h 53 54 cmakeDir = "cmake"; 55 cmakeFlags = [ 56 "-DBUILD_SHARED_LIBS=ON" 57 ] 58 ++ lib.optional enableEGL "-DGLEW_EGL=ON"; 59 60 postInstall = '' 61 moveToOutput lib/cmake "''${!outputDev}" 62 moveToOutput lib/pkgconfig "''${!outputDev}" 63 64 cat >> "''${!outputDev}"/lib/cmake/glew/glew-config.cmake <<EOF 65 # nixpkg's workaround for a cmake bug 66 # https://discourse.cmake.org/t/the-findglew-cmake-module-does-not-set-glew-libraries-in-some-cases/989/3 67 set(GLEW_VERSION "$version") 68 set(GLEW_LIBRARIES GLEW::glew\''${_glew_target_postfix}) 69 get_target_property(GLEW_INCLUDE_DIRS GLEW::glew\''${_glew_target_postfix} INTERFACE_INCLUDE_DIRECTORIES) 70 set_target_properties(GLEW::GLEW\''${_glew_target_postfix} PROPERTIES 71 IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE "" 72 IMPORTED_IMPLIB_RELEASE "GLEW" 73 IMPORTED_IMPLIB_DEBUG "GLEW" 74 ) 75 EOF 76 ''; 77 78 passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; 79 80 meta = with lib; { 81 description = "OpenGL extension loading library for C/C++"; 82 homepage = "https://glew.sourceforge.net/"; 83 license = with licenses; [ 84 # modified bsd 85 free 86 mit 87 gpl2Only 88 ]; # For full details, see https://github.com/nigels-com/glew#copyright-and-licensing 89 pkgConfigModules = [ "glew" ]; 90 platforms = 91 with platforms; 92 if enableEGL then subtractLists darwin mesa.meta.platforms else mesa.meta.platforms; 93 }; 94})