3
0
Fork 0
forked from mirrors/nixpkgs

glm: 0.9.8.5 -> 0.9.9.8

Bump abandoned package to close #132479.

- Use fetchFromGitHub to download the archive.

- No need for the updated platform.h patch. The released archive builds
  with default stdenv. (It may be needed again in the future?.)

- Use the proper attribute to set CMake flags.

- Don't build the (dummy?) libraries. They are not used anyway by any
  other target nor made available by the glmConfig.cmake file.

- Build and run the tests now.

- Don't define the GLM_COMPILER macro on Darwin. Doesn't seem necessary
  anymore, there are no errors without it. (And it is not even documented
  what was the original error that required it to be defined.)

- Upstream became package-unfriendly and removed the install command,
  so it needs to be installed manually.

  - Don't set the now unsupported CMake option GLM_INSTALL_ENABLE.

  - Remove unwanted files from the include directory.

  - Fix glmConfig.cmake with the proper path to the include directory.

  - While on it, install a custom pkg-config file, since it is trivial.

  - Don't install unnecessary files as documentation.

- Since I practically rewrote the entire derivation and the package is
  abandoned, add myself as maintainer (I guess?).
This commit is contained in:
Sebastián Mancilla 2021-08-19 19:26:40 -04:00
parent 5204dee265
commit 7e59877fe1
2 changed files with 46 additions and 23 deletions

View file

@ -1,37 +1,53 @@
{ lib, stdenv, fetchurl, fetchzip, cmake }:
{ lib, stdenv, fetchFromGitHub, cmake }:
stdenv.mkDerivation rec {
version = "0.9.8.5";
version = "0.9.9.8";
pname = "glm";
src = fetchzip {
url = "https://github.com/g-truc/glm/releases/download/${version}/${pname}-${version}.zip";
sha256 = "0dkfj4hin3am9fxgcvwr5gj0h9y52x7wa03lfwb3q0bvaj1rsly2";
src = fetchFromGitHub {
owner = "g-truc";
repo = pname;
rev = version;
sha256 = "sha256-F//+3L5Ozrw6s7t4LrcUmO7sN30ZSESdrPAYX57zgr8=";
};
nativeBuildInputs = [ cmake ];
outputs = [ "out" "doc" ];
cmakeConfigureFlags = [ "-DGLM_INSTALL_ENABLE=off" ];
nativeBuildInputs = [ cmake ];
# fetch newer version of platform.h which correctly supports gcc 7.3
gcc7PlatformPatch = fetchurl {
url = "https://raw.githubusercontent.com/g-truc/glm/384dab02e45a8ad3c1a3fa0906e0d5682c5b27b9/glm/simd/platform.h";
sha256 = "0ym0sgwznxhfyi014xs55x3ql7r65fjs34sqb5jiaffkdhkqgzia";
};
cmakeFlags = [
"-DBUILD_SHARED_LIBS=OFF"
"-DBUILD_STATIC_LIBS=OFF"
"-DGLM_TEST_ENABLE=${if doCheck then "ON" else "OFF"}"
];
postPatch = ''
substituteInPlace CMakeLists.txt \
--replace '"''${CMAKE_CURRENT_BINARY_DIR}/''${GLM_INSTALL_CONFIGDIR}' '"''${GLM_INSTALL_CONFIGDIR}'
cp ${gcc7PlatformPatch} glm/simd/platform.h
'';
doCheck = true;
NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin "-DGLM_COMPILER=0";
installPhase = ''
runHook preInstall
postInstall = ''
# Install header-only library
mkdir -p $out/include
cp -rv ../glm $out/include
rm $out/include/glm/CMakeLists.txt
rm $out/include/glm/detail/*.cpp
# Install CMake files
mkdir -p $out/lib
cp -rv ../cmake $out/lib
substituteInPlace $out/lib/cmake/glm/glmConfig.cmake \
--replace 'GLM_INCLUDE_DIRS ''${_IMPORT_PREFIX}' "GLM_INCLUDE_DIRS $out/include"
# Install pkg-config file
mkdir -p $out/lib/pkgconfig
substituteAll ${./glm.pc.in} $out/lib/pkgconfig/glm.pc
# Install docs
mkdir -p $doc/share/doc/glm
cp -rv $NIX_BUILD_TOP/$sourceRoot/doc/* $doc/share/doc/glm
cp -rv ../doc/api $doc/share/doc/glm/html
cp -v ../doc/manual.pdf $doc/share/doc/glm
runHook postInstall
'';
meta = with lib; {
@ -41,10 +57,10 @@ stdenv.mkDerivation rec {
graphics software based on the OpenGL Shading Language (GLSL)
specification and released under the MIT license.
'';
homepage = "http://glm.g-truc.net/";
homepage = "https://github.com/g-truc/glm";
license = licenses.mit;
platforms = platforms.unix;
maintainers = with lib.maintainers; [ ];
maintainers = with maintainers; [ smancill ];
};
}

View file

@ -0,0 +1,7 @@
prefix=@out@
includedir=@out@/include
Name: GLM
Description: OpenGL Mathematics
Version: @version@
Cflags: -I${includedir}