mini-calc: 3.3.3 -> 3.3.5 (#372274)
[NixPkgs.git] / pkgs / by-name / li / libe57format / package.nix
blobbf391abd82d83cd020d9adb243088b93a5e6db7b
2   lib,
3   stdenv,
4   cmake,
5   fetchFromGitHub,
6   fetchpatch,
7   xercesc,
8 }:
10 stdenv.mkDerivation (finalAttrs: {
11   pname = "libe57format";
12   version = "3.1.1";
14   src = fetchFromGitHub {
15     owner = "asmaloney";
16     repo = "libE57Format";
17     rev = "v${finalAttrs.version}";
18     hash = "sha256-bOuWh9Nkxva2v0M6+vnAya8EW/G3WQePxHakQt8T9NE=";
19     fetchSubmodules = true; # for submodule-vendored libraries such as `gtest`
20   };
22   # Repository of E57 files used for testing.
23   libE57Format-test-data_src = fetchFromGitHub {
24     owner = "asmaloney";
25     repo = "libE57Format-test-data";
26     rev = "4960564a732c6444c50dfae5b2273e68837399cd";
27     hash = "sha256-k26yVbYSQJ3EMgcpjm35N1OAxarFmfMvzfTN2Hdyu8c=";
28   };
30   CXXFLAGS = [
31     # GCC 13: error: 'int16_t' has not been declared in 'std'
32     "-include cstdint"
33   ];
35   patches = [
36     # TODO: Remove with the next release: https://github.com/asmaloney/libE57Format/pull/299
37     (fetchpatch {
38       name = "libE57Format-Dont-force-warnings-as-errors-when-building-self.patch"; # https://github.com/apache/thrift/pull/2726
39       url = "https://github.com/asmaloney/libE57Format/commit/66bb5af15937b4c10a7f412ca4d1673f42bbad28.patch";
40       hash = "sha256-2cNURjMLP0TijYY5gbuWLE7H/PlMW936wAeOqJ/w9C0=";
41     })
43   ];
45   nativeBuildInputs = [
46     cmake
47   ];
49   buildInputs = [
50     xercesc
51   ];
53   cmakeFlags = [
54     # See https://github.com/asmaloney/libE57Format/blob/9372bdea8db2cc0c032a08f6d655a53833d484b8/test/README.md
55     (
56       if finalAttrs.finalPackage.doCheck then
57         "-DE57_TEST_DATA_PATH=${finalAttrs.libE57Format-test-data_src}"
58       else
59         "-DE57_BUILD_TEST=OFF"
60     )
61   ];
63   doCheck = true;
65   postCheck = ''
66     ./testE57
67   '';
69   # The build system by default builds ONLY static libraries, and with
70   # `-DE57_BUILD_SHARED=ON` builds ONLY shared libraries, see:
71   #     https://github.com/asmaloney/libE57Format/issues/48
72   #     https://github.com/asmaloney/libE57Format/blob/f657d470da5f0d185fe371c4c011683f6e30f0cb/CMakeLists.txt#L82-L89
73   # We support building both by building statically and then
74   # building an .so file here manually.
75   # The way this is written makes this Linux-only for now.
76   postInstall = ''
77     cd $out/lib
78     g++ -Wl,--no-undefined -shared -o libE57FormatShared.so -L. -Wl,-whole-archive -lE57Format -Wl,-no-whole-archive -lxerces-c
79     mv libE57FormatShared.so libE57Format.so
81     if [ "$dontDisableStatic" -ne "1" ]; then
82       rm libE57Format.a
83     fi
84   '';
86   meta = with lib; {
87     description = "Library for reading & writing the E57 file format";
88     homepage = "https://github.com/asmaloney/libE57Format";
89     license = licenses.boost;
90     maintainers = with maintainers; [
91       chpatrick
92       nh2
93     ];
94     platforms = platforms.linux; # because of the .so buiding in `postInstall` above
95   };