1{ stdenv
2, fetchpatch
3, fetchFromGitLab
4, cmake
5, ninja
6, pkg-config
7, boost
8, glib
9, gsl
10, cairo
11, double-conversion
12, gtest
13, lib
14}:
15
16stdenv.mkDerivation rec {
17 pname = "lib2geom";
18 version = "1.3";
19
20 outputs = [ "out" "dev" ];
21
22 src = fetchFromGitLab {
23 owner = "inkscape";
24 repo = "lib2geom";
25 rev = "refs/tags/${version}";
26 hash = "sha256-llUpW8VRBD8RKaGfyedzsMbLRb8DIo0ePt6m2T2w7Po=";
27 };
28
29 patches = [
30 # Fix compilation with Clang.
31 # https://gitlab.com/inkscape/lib2geom/-/merge_requests/102
32 (fetchpatch {
33 url = "https://gitlab.com/inkscape/lib2geom/-/commit/a5b5ac7d992023f8a80535ede60421e73ecd8e20.patch";
34 hash = "sha256-WJYkk3WRYVyPSvyTbKDUrYvUwFgKA9mmTiEWtYQqM4Q=";
35 })
36 (fetchpatch {
37 url = "https://gitlab.com/inkscape/lib2geom/-/commit/23d9393af4bee17aeb66a3c13bdad5dbed982d08.patch";
38 hash = "sha256-LAaGMIXpDI/Wzv5E2LasW1Y2/G4ukhuEzDmFu3AzZOA=";
39 })
40 ];
41
42 nativeBuildInputs = [
43 cmake
44 ninja
45 pkg-config
46 ];
47
48 buildInputs = [
49 boost
50 glib
51 gsl
52 cairo
53 double-conversion
54 ];
55
56 nativeCheckInputs = [
57 gtest
58 ];
59
60 cmakeFlags = [
61 "-D2GEOM_BUILD_SHARED=ON"
62 ];
63
64 doCheck = true;
65
66 # TODO: Update cmake hook to make it simpler to selectively disable cmake tests: #113829
67 checkPhase = let
68 disabledTests =
69 lib.optionals stdenv.isAarch64 [
70 # Broken on all platforms, test just accidentally passes on some.
71 # https://gitlab.com/inkscape/lib2geom/-/issues/63
72 "elliptical-arc-test"
73 ];
74 in ''
75 runHook preCheck
76 ctest --output-on-failure -E '^${lib.concatStringsSep "|" disabledTests}$'
77 runHook postCheck
78 '';
79
80 meta = with lib; {
81 description = "Easy to use 2D geometry library in C++";
82 homepage = "https://gitlab.com/inkscape/lib2geom";
83 license = [ licenses.lgpl21Only licenses.mpl11 ];
84 maintainers = with maintainers; [ jtojnar ];
85 platforms = platforms.unix;
86 };
87}