Unverified Commit 514f9249 authored by Sandro Jäckel's avatar Sandro Jäckel
Browse files

glm_1_0_1: init

parent b9c7f0e6
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
{
  callPackage,
  fetchFromGitHub,
}:

callPackage ./generic.nix rec {
  version = "1.0.1";

  src = fetchFromGitHub {
    owner = "g-truc";
    repo = "glm";
    rev = version;
    sha256 = "sha256-GnGyzNRpzuguc3yYbEFtYLvG+KiCtRAktiN+NvbOICE=";
  };
}
+72 −0
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  fetchFromGitHub,
  cmake,

  version,
  src,
}:

stdenv.mkDerivation rec {
  pname = "glm";
  inherit version src;

  outputs = [
    "out"
    "doc"
  ];

  patches = lib.optionals stdenv.hostPlatform.isLinux [
    # Remove when https://github.com/g-truc/glm/pull/1001 merged & in release.
    # Relies on <endian.h>, Linux-specific
    ./1001-glm-Fix-packing-on-BE.patch
  ];

  nativeBuildInputs = [ cmake ];

  env.NIX_CFLAGS_COMPILE =
    # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102823
    if (stdenv.cc.isGNU && lib.versionAtLeast stdenv.cc.version "11") then
      "-fno-ipa-modref"
    # Fix compilation errors on darwin
    else if (stdenv.cc.isClang) then
      "-Wno-error"
    else
      "";

  cmakeFlags = [
    (lib.cmakeBool "BUILD_SHARED_LIBS" false)
    (lib.cmakeBool "BUILD_STATIC_LIBS" false)
    (lib.cmakeBool "GLM_TEST_ENABLE" doCheck)
  ];

  doCheck = true;

  postInstall = ''
    # 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
  '';

  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;
    # https://github.com/g-truc/glm/issues/897 indicates that packing isn't implemented properly on non-LE.
    # Patch from https://github.com/g-truc/glm/pull/1001 currently relies on Linux-only header.
    broken = !stdenv.hostPlatform.isLittleEndian && !stdenv.hostPlatform.isLinux;
    maintainers = with maintainers; [ smancill ];
  };
}
+2 −63
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  callPackage,
  fetchFromGitHub,
  cmake,
}:

stdenv.mkDerivation rec {
callPackage ./generic.nix rec {
  version = "1.0.2";
  pname = "glm";

  src = fetchFromGitHub {
    owner = "g-truc";
@@ -15,62 +12,4 @@ stdenv.mkDerivation rec {
    rev = version;
    sha256 = "sha256-2xKv1nO+OdwA0r+I9OZ+OCL9dJFg/LJsQfIvIF76vc0=";
  };

  outputs = [
    "out"
    "doc"
  ];

  patches = lib.optionals stdenv.hostPlatform.isLinux [
    # Remove when https://github.com/g-truc/glm/pull/1001 merged & in release.
    # Relies on <endian.h>, Linux-specific
    ./1001-glm-Fix-packing-on-BE.patch
  ];

  nativeBuildInputs = [ cmake ];

  env.NIX_CFLAGS_COMPILE =
    # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102823
    if (stdenv.cc.isGNU && lib.versionAtLeast stdenv.cc.version "11") then
      "-fno-ipa-modref"
    # Fix compilation errors on darwin
    else if (stdenv.cc.isClang) then
      "-Wno-error"
    else
      "";

  cmakeFlags = [
    (lib.cmakeBool "BUILD_SHARED_LIBS" false)
    (lib.cmakeBool "BUILD_STATIC_LIBS" false)
    (lib.cmakeBool "GLM_TEST_ENABLE" doCheck)
  ];

  doCheck = true;

  postInstall = ''
    # 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
  '';

  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;
    # https://github.com/g-truc/glm/issues/897 indicates that packing isn't implemented properly on non-LE.
    # Patch from https://github.com/g-truc/glm/pull/1001 currently relies on Linux-only header.
    broken = !stdenv.hostPlatform.isLittleEndian && !stdenv.hostPlatform.isLinux;
    maintainers = with maintainers; [ smancill ];
  };
}
+2 −0
Original line number Diff line number Diff line
@@ -1659,6 +1659,8 @@ with pkgs;

  glances = python3Packages.callPackage ../applications/system/glances { };

  glm_1_0_1 = callPackage ../by-name/gl/glm/1_0_1.nix { };

  go2tv-lite = go2tv.override { withGui = false; };

  guglielmo = libsForQt5.callPackage ../applications/radio/guglielmo { };