1 { lib, stdenv, fetchurl, fetchpatch, cmake, libGLU, libXmu, libXi, libXext
7 stdenv.mkDerivation (finalAttrs: {
12 url = "mirror://sourceforge/glew/${finalAttrs.pname}-${finalAttrs.version}.tgz";
13 sha256 = "1qak8f7g1iswgswrgkzc7idk7jmqgwrs58fhg2ai007v7j4q5z6l";
16 outputs = [ "bin" "out" "dev" ];
19 # https://github.com/nigels-com/glew/pull/342
21 url = "https://github.com/nigels-com/glew/commit/966e53fa153175864e151ec8a8e11f688c3e752d.diff";
22 sha256 = "sha256-xsSwdAbdWZA4KVoQhaLlkYvO711i3QlHGtv6v1Omkhw=";
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
32 "-DBUILD_SHARED_LIBS=ON"
33 ] ++ lib.optional enableEGL "-DGLEW_EGL=ON";
36 moveToOutput lib/cmake "''${!outputDev}"
37 moveToOutput lib/pkgconfig "''${!outputDev}"
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"
53 passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
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;
62 subtractLists darwin mesaPlatforms