nixpkgs/pkgs/development/libraries/glew/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

58 lines
1.9 KiB
Nix
Raw Normal View History

2022-01-05 04:25:03 +00:00
{ lib, stdenv, fetchurl, fetchpatch, cmake, libGLU, xlibsWrapper, libXmu, libXi
, OpenGL
2022-01-05 04:25:03 +00:00
, enableEGL ? false
}:
stdenv.mkDerivation rec {
2021-06-22 13:21:29 +00:00
pname = "glew";
version = "2.2.0";
src = fetchurl {
2021-06-22 13:21:29 +00:00
url = "mirror://sourceforge/glew/${pname}-${version}.tgz";
2020-04-05 16:16:00 +00:00
sha256 = "1qak8f7g1iswgswrgkzc7idk7jmqgwrs58fhg2ai007v7j4q5z6l";
};
2022-01-05 04:25:03 +00:00
outputs = [ "bin" "out" "dev" ];
2022-01-05 04:25:03 +00:00
patches = [
# https://github.com/nigels-com/glew/pull/342
(fetchpatch {
url = "https://github.com/nigels-com/glew/commit/966e53fa153175864e151ec8a8e11f688c3e752d.diff";
sha256 = "sha256-xsSwdAbdWZA4KVoQhaLlkYvO711i3QlHGtv6v1Omkhw=";
})
];
2022-01-05 04:25:03 +00:00
nativeBuildInputs = [ cmake ];
buildInputs = lib.optionals (!stdenv.isDarwin) [ xlibsWrapper libXmu libXi ];
propagatedBuildInputs = if stdenv.isDarwin then [ OpenGL ] else [ libGLU ]; # GL/glew.h includes GL/glu.h
2022-01-05 04:25:03 +00:00
cmakeDir = "cmake";
cmakeFlags = [
"-DBUILD_SHARED_LIBS=ON"
] ++ lib.optional enableEGL "-DGLEW_EGL=ON";
postInstall = ''
2022-01-05 04:25:03 +00:00
moveToOutput lib/cmake "''${!outputDev}"
moveToOutput lib/pkgconfig "''${!outputDev}"
cat >> "''${!outputDev}"/lib/cmake/glew/glew-config.cmake <<EOF
# nixpkg's workaround for a cmake bug
# https://discourse.cmake.org/t/the-findglew-cmake-module-does-not-set-glew-libraries-in-some-cases/989/3
set(GLEW_VERSION "$version")
set(GLEW_LIBRARIES GLEW::glew\''${_glew_target_postfix})
get_target_property(GLEW_INCLUDE_DIRS GLEW::glew\''${_glew_target_postfix} INTERFACE_INCLUDE_DIRECTORIES)
EOF
'';
meta = with lib; {
2022-01-05 04:25:03 +00:00
description = "An OpenGL extension loading library for C/C++";
homepage = "http://glew.sourceforge.net/";
2022-01-05 04:25:03 +00:00
license = with licenses; [ /* modified bsd */ free mit gpl2Only ]; # For full details, see https://github.com/nigels-com/glew#copyright-and-licensing
platforms = with platforms;
if enableEGL then
subtractLists darwin mesaPlatforms
else
mesaPlatforms;
};
}