Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib 2, stdenv 3, fetchFromGitHub 4, fetchpatch 5, cmake 6}: 7 8stdenv.mkDerivation rec { 9 version = "0.9.9.8"; 10 pname = "glm"; 11 12 src = fetchFromGitHub { 13 owner = "g-truc"; 14 repo = pname; 15 rev = version; 16 sha256 = "sha256-F//+3L5Ozrw6s7t4LrcUmO7sN30ZSESdrPAYX57zgr8="; 17 }; 18 19 # https://github.com/g-truc/glm/pull/1055 20 # Fix more implicit-int-float-conversion warnings 21 # (https://github.com/g-truc/glm/pull/986 wasn't enough, and -Werror is used) 22 patches = [(fetchpatch { 23 url = "https://github.com/kraj/glm/commit/bd9b5060bc3b9581090d44f15b4e236566ea86a6.patch"; 24 sha256 = "sha256-QO4o/wV564kJimBcEyr9TWzREEnRJ1n0j0HPojN4pkI="; 25 })]; 26 27 outputs = [ "out" "doc" ]; 28 29 nativeBuildInputs = [ cmake ]; 30 31 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102823 32 env.NIX_CFLAGS_COMPILE = lib.optionalString (stdenv.cc.isGNU && lib.versionAtLeast stdenv.cc.version "11") "-fno-ipa-modref"; 33 34 cmakeFlags = [ 35 "-DBUILD_SHARED_LIBS=OFF" 36 "-DBUILD_STATIC_LIBS=OFF" 37 "-DGLM_TEST_ENABLE=${if doCheck then "ON" else "OFF"}" 38 ]; 39 40 doCheck = true; 41 42 installPhase = '' 43 runHook preInstall 44 45 # Install header-only library 46 mkdir -p $out/include 47 cp -rv ../glm $out/include 48 rm $out/include/glm/CMakeLists.txt 49 rm $out/include/glm/detail/*.cpp 50 51 # Install CMake files 52 mkdir -p $out/lib 53 cp -rv ../cmake $out/lib 54 substituteInPlace $out/lib/cmake/glm/glmConfig.cmake \ 55 --replace 'GLM_INCLUDE_DIRS ''${_IMPORT_PREFIX}' "GLM_INCLUDE_DIRS $out/include" 56 57 # Install pkg-config file 58 mkdir -p $out/lib/pkgconfig 59 substituteAll ${./glm.pc.in} $out/lib/pkgconfig/glm.pc 60 61 # Install docs 62 mkdir -p $doc/share/doc/glm 63 cp -rv ../doc/api $doc/share/doc/glm/html 64 cp -v ../doc/manual.pdf $doc/share/doc/glm 65 66 runHook postInstall 67 ''; 68 69 meta = with lib; { 70 description = "OpenGL Mathematics library for C++"; 71 longDescription = '' 72 OpenGL Mathematics (GLM) is a header only C++ mathematics library for 73 graphics software based on the OpenGL Shading Language (GLSL) 74 specification and released under the MIT license. 75 ''; 76 homepage = "https://github.com/g-truc/glm"; 77 license = licenses.mit; 78 platforms = platforms.unix; 79 maintainers = with maintainers; [ smancill ]; 80 }; 81} 82