about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/glm
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/glm')
-rw-r--r--nixpkgs/pkgs/development/libraries/glm/default.nix60
-rw-r--r--nixpkgs/pkgs/development/libraries/glm/glm.pc.in7
2 files changed, 45 insertions, 22 deletions
diff --git a/nixpkgs/pkgs/development/libraries/glm/default.nix b/nixpkgs/pkgs/development/libraries/glm/default.nix
index f5652a61c1de..ef8cd49ba297 100644
--- a/nixpkgs/pkgs/development/libraries/glm/default.nix
+++ b/nixpkgs/pkgs/development/libraries/glm/default.nix
@@ -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=";
   };
 
+  outputs = [ "out" "doc" ];
+
   nativeBuildInputs = [ cmake ];
 
-  outputs = [ "out" "doc" ];
+  cmakeFlags = [
+    "-DBUILD_SHARED_LIBS=OFF"
+    "-DBUILD_STATIC_LIBS=OFF"
+    "-DGLM_TEST_ENABLE=${if doCheck then "ON" else "OFF"}"
+  ];
 
-  cmakeConfigureFlags = [ "-DGLM_INSTALL_ENABLE=off" ];
+  doCheck = true;
 
-  # 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";
-  };
+  installPhase = ''
+    runHook preInstall
 
-  postPatch = ''
-    substituteInPlace CMakeLists.txt \
-      --replace '"''${CMAKE_CURRENT_BINARY_DIR}/''${GLM_INSTALL_CONFIGDIR}' '"''${GLM_INSTALL_CONFIGDIR}'
-    cp ${gcc7PlatformPatch} glm/simd/platform.h
-  '';
+    # 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"
 
-  NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin "-DGLM_COMPILER=0";
+    # Install pkg-config file
+    mkdir -p $out/lib/pkgconfig
+    substituteAll ${./glm.pc.in} $out/lib/pkgconfig/glm.pc
 
-  postInstall = ''
+    # 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 ];
   };
 }
 
diff --git a/nixpkgs/pkgs/development/libraries/glm/glm.pc.in b/nixpkgs/pkgs/development/libraries/glm/glm.pc.in
new file mode 100644
index 000000000000..e196c793d1d5
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/glm/glm.pc.in
@@ -0,0 +1,7 @@
+prefix=@out@
+includedir=@out@/include
+
+Name: GLM
+Description: OpenGL Mathematics
+Version: @version@
+Cflags: -I${includedir}