1{
2 lib, stdenv,
3 cmake,
4 fetchpatch,
5 fetchFromGitHub,
6 boost,
7 xercesc,
8 icu,
9}:
10
11stdenv.mkDerivation rec {
12 pname = "libe57format";
13 version = "2.2.0";
14
15 src = fetchFromGitHub {
16 owner = "asmaloney";
17 repo = "libE57Format";
18 rev = "v${version}";
19 sha256 = "15l23spjvak5h3n7aj3ggy0c3cwcg8mvnc9jlbd9yc2ra43bx7bp";
20 };
21
22 patches = [
23 # gcc11 header fix
24 (fetchpatch {
25 url = "https://github.com/asmaloney/libE57Format/commit/13f6a16394ce3eb50ea4cd21f31f77f53294e8d0.patch";
26 sha256 = "sha256-4vVhKrCxnWO106DSAk+xxo4uk6zC89m9VQAPaDJ8Ed4=";
27 })
28 ];
29 CXXFLAGS = [
30 # GCC 13: error: 'int16_t' has not been declared in 'std'
31 "-include cstdint"
32 ];
33
34 nativeBuildInputs = [
35 cmake
36 ];
37
38 buildInputs = [
39 boost
40 icu
41 ];
42
43 propagatedBuildInputs = [
44 # Necessary for projects that try to find libE57Format via CMake
45 # due to the way that libe57format's CMake config is written.
46 xercesc
47 ];
48
49 # The build system by default builds ONLY static libraries, and with
50 # `-DE57_BUILD_SHARED=ON` builds ONLY shared libraries, see:
51 # https://github.com/asmaloney/libE57Format/issues/48
52 # https://github.com/asmaloney/libE57Format/blob/f657d470da5f0d185fe371c4c011683f6e30f0cb/CMakeLists.txt#L82-L89
53 # We support building both by building statically and then
54 # building an .so file here manually.
55 # The way this is written makes this Linux-only for now.
56 postInstall = ''
57 cd $out/lib
58 g++ -Wl,--no-undefined -shared -o libE57FormatShared.so -L. -Wl,-whole-archive -lE57Format -Wl,-no-whole-archive -lxerces-c
59 mv libE57FormatShared.so libE57Format.so
60
61 if [ "$dontDisableStatic" -ne "1" ]; then
62 rm libE57Format.a
63 fi
64 '';
65
66 meta = with lib; {
67 description = "Library for reading & writing the E57 file format";
68 homepage = "https://github.com/asmaloney/libE57Format";
69 license = licenses.boost;
70 maintainers = with maintainers; [ chpatrick nh2 ];
71 platforms = platforms.linux; # because of the .so buiding in `postInstall` above
72 };
73}