2024-09-19 14:19:46 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchurl
|
|
|
|
, fetchpatch
|
|
|
|
, cmake
|
|
|
|
, libGLU
|
|
|
|
, libXmu
|
|
|
|
, libXi
|
|
|
|
, libXext
|
2021-01-05 17:05:55 +00:00
|
|
|
, OpenGL
|
2024-09-19 14:19:46 +00:00
|
|
|
, enableEGL ? (!stdenv.isDarwin)
|
2023-02-16 17:41:37 +00:00
|
|
|
, testers
|
2024-09-19 14:19:46 +00:00
|
|
|
, mesa
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2023-02-16 17:41:37 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2021-07-21 07:28:18 +00:00
|
|
|
pname = "glew";
|
|
|
|
version = "2.2.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2024-07-27 06:49:29 +00:00
|
|
|
url = "mirror://sourceforge/glew/glew-${finalAttrs.version}.tgz";
|
2020-05-15 21:57:56 +00:00
|
|
|
sha256 = "1qak8f7g1iswgswrgkzc7idk7jmqgwrs58fhg2ai007v7j4q5z6l";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-01-13 20:06:32 +00:00
|
|
|
outputs = [ "bin" "out" "dev" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-01-13 20:06:32 +00:00
|
|
|
patches = [
|
|
|
|
# https://github.com/nigels-com/glew/pull/342
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/nigels-com/glew/commit/966e53fa153175864e151ec8a8e11f688c3e752d.diff";
|
2024-09-19 14:19:46 +00:00
|
|
|
hash = "sha256-xsSwdAbdWZA4KVoQhaLlkYvO711i3QlHGtv6v1Omkhw=";
|
|
|
|
})
|
|
|
|
|
|
|
|
# don't make EGL support disable GLX, use the same patch as ArchLinux
|
|
|
|
# https://gitlab.archlinux.org/archlinux/packaging/packages/glew/-/blob/ca08ff5d4cd3548a593eb1118d0a84b0c3670349/egl+glx.patch
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://gitlab.archlinux.org/archlinux/packaging/packages/glew/-/raw/ca08ff5d4cd3548a593eb1118d0a84b0c3670349/egl+glx.patch?inline=false";
|
|
|
|
hash = "sha256-IG3FPhhaor1kshEH3Kr8yzIHqBhczRwCqH7ZeDwlzGE=";
|
2022-01-13 20:06:32 +00:00
|
|
|
})
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-01-13 20:06:32 +00:00
|
|
|
nativeBuildInputs = [ cmake ];
|
2022-11-04 12:27:35 +00:00
|
|
|
buildInputs = lib.optionals (!stdenv.isDarwin) [ libXmu libXi libXext ];
|
2022-01-13 20:06:32 +00:00
|
|
|
propagatedBuildInputs = if stdenv.isDarwin then [ OpenGL ] else [ libGLU ]; # GL/glew.h includes GL/glu.h
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-01-13 20:06:32 +00:00
|
|
|
cmakeDir = "cmake";
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DBUILD_SHARED_LIBS=ON"
|
|
|
|
] ++ lib.optional enableEGL "-DGLEW_EGL=ON";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
postInstall = ''
|
2022-01-13 20:06:32 +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)
|
2023-03-04 12:14:45 +00:00
|
|
|
set_target_properties(GLEW::GLEW\''${_glew_target_postfix} PROPERTIES
|
|
|
|
IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE ""
|
|
|
|
IMPORTED_IMPLIB_RELEASE "GLEW"
|
|
|
|
IMPORTED_IMPLIB_DEBUG "GLEW"
|
|
|
|
)
|
2022-01-13 20:06:32 +00:00
|
|
|
EOF
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2023-02-16 17:41:37 +00:00
|
|
|
passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2024-06-20 14:57:18 +00:00
|
|
|
description = "OpenGL extension loading library for C/C++";
|
2023-02-02 18:25:31 +00:00
|
|
|
homepage = "https://glew.sourceforge.net/";
|
2022-01-13 20:06:32 +00:00
|
|
|
license = with licenses; [ /* modified bsd */ free mit gpl2Only ]; # For full details, see https://github.com/nigels-com/glew#copyright-and-licensing
|
2023-02-16 17:41:37 +00:00
|
|
|
pkgConfigModules = [ "glew" ];
|
2022-01-13 20:06:32 +00:00
|
|
|
platforms = with platforms;
|
|
|
|
if enableEGL then
|
2024-09-19 14:19:46 +00:00
|
|
|
subtractLists darwin mesa.meta.platforms
|
2022-01-13 20:06:32 +00:00
|
|
|
else
|
2024-09-19 14:19:46 +00:00
|
|
|
mesa.meta.platforms;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2023-02-16 17:41:37 +00:00
|
|
|
})
|