nixpkgs/pkgs/development/libraries/glm/default.nix
Sebastián Mancilla 7e59877fe1 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?).
2021-09-16 17:54:52 -03:00

66 lines
1.7 KiB
Nix

{ lib, stdenv, fetchFromGitHub, cmake }:
stdenv.mkDerivation rec {
version = "0.9.9.8";
pname = "glm";
src = fetchFromGitHub {
owner = "g-truc";
repo = pname;
rev = version;
sha256 = "sha256-F//+3L5Ozrw6s7t4LrcUmO7sN30ZSESdrPAYX57zgr8=";
};
outputs = [ "out" "doc" ];
nativeBuildInputs = [ cmake ];
cmakeFlags = [
"-DBUILD_SHARED_LIBS=OFF"
"-DBUILD_STATIC_LIBS=OFF"
"-DGLM_TEST_ENABLE=${if doCheck then "ON" else "OFF"}"
];
doCheck = true;
installPhase = ''
runHook preInstall
# 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 ../doc/api $doc/share/doc/glm/html
cp -v ../doc/manual.pdf $doc/share/doc/glm
runHook postInstall
'';
meta = with lib; {
description = "OpenGL Mathematics library for C++";
longDescription = ''
OpenGL Mathematics (GLM) is a header only C++ mathematics library for
graphics software based on the OpenGL Shading Language (GLSL)
specification and released under the MIT license.
'';
homepage = "https://github.com/g-truc/glm";
license = licenses.mit;
platforms = platforms.unix;
maintainers = with maintainers; [ smancill ];
};
}