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
30 nativeBuildInputs = [
31 cmake
32 ];
33
34 buildInputs = [
35 boost
36 icu
37 ];
38
39 propagatedBuildInputs = [
40 # Necessary for projects that try to find libE57Format via CMake
41 # due to the way that libe57format's CMake config is written.
42 xercesc
43 ];
44
45 # The build system by default builds ONLY static libraries, and with
46 # `-DE57_BUILD_SHARED=ON` builds ONLY shared libraries, see:
47 # https://github.com/asmaloney/libE57Format/issues/48
48 # https://github.com/asmaloney/libE57Format/blob/f657d470da5f0d185fe371c4c011683f6e30f0cb/CMakeLists.txt#L82-L89
49 # We support building both by building statically and then
50 # building an .so file here manually.
51 # The way this is written makes this Linux-only for now.
52 postInstall = ''
53 cd $out/lib
54 g++ -Wl,--no-undefined -shared -o libE57FormatShared.so -L. -Wl,-whole-archive -lE57Format -Wl,-no-whole-archive -lxerces-c
55 mv libE57FormatShared.so libE57Format.so
56
57 if [ "$dontDisableStatic" -ne "1" ]; then
58 rm libE57Format.a
59 fi
60 '';
61
62 meta = with lib; {
63 description = "Library for reading & writing the E57 file format";
64 homepage = "https://github.com/asmaloney/libE57Format";
65 license = licenses.boost;
66 maintainers = with maintainers; [ chpatrick nh2 ];
67 platforms = platforms.linux; # because of the .so buiding in `postInstall` above
68 };
69}