lol
1{ lib
2, stdenv
3, fetchFromGitHub
4, cmake
5, enableVTK ? true
6, vtk
7, ApplicationServices
8, Cocoa
9, libiconv
10, enablePython ? false
11, python ? null
12, swig4
13, expat
14, libuuid
15, openjpeg
16, zlib
17, pkg-config
18}:
19
20stdenv.mkDerivation rec {
21 pname = "gdcm";
22 version = "3.0.22";
23
24 src = fetchFromGitHub {
25 owner = "malaterre";
26 repo = "GDCM";
27 rev = "refs/tags/v${version}";
28 hash = "sha256-geWNGbBJGKPs5hNO42vtVOj0rOWyM6zmcocvRhWW4s0=";
29 };
30
31 cmakeFlags = [
32 "-DGDCM_BUILD_APPLICATIONS=ON"
33 "-DGDCM_BUILD_SHARED_LIBS=ON"
34 "-DGDCM_BUILD_TESTING=ON"
35 "-DGDCM_USE_SYSTEM_EXPAT=ON"
36 "-DGDCM_USE_SYSTEM_ZLIB=ON"
37 "-DGDCM_USE_SYSTEM_UUID=ON"
38 "-DGDCM_USE_SYSTEM_OPENJPEG=ON"
39 # hack around usual "`RUNTIME_DESTINATION` must not be an absolute path" issue:
40 "-DCMAKE_INSTALL_LIBDIR=lib"
41 "-DCMAKE_INSTALL_BINDIR=bin"
42 "-DCMAKE_INSTALL_INCLUDEDIR=include"
43 ] ++ lib.optionals enableVTK [
44 "-DGDCM_USE_VTK=ON"
45 ] ++ lib.optionals enablePython [
46 "-DGDCM_WRAP_PYTHON:BOOL=ON"
47 "-DGDCM_INSTALL_PYTHONMODULE_DIR=${placeholder "out"}/${python.sitePackages}"
48 ];
49
50 nativeBuildInputs = [
51 cmake
52 pkg-config
53 ];
54
55 buildInputs = [
56 expat
57 libuuid
58 openjpeg
59 zlib
60 ] ++ lib.optionals enableVTK [
61 vtk
62 ] ++ lib.optionals stdenv.isDarwin [
63 ApplicationServices
64 Cocoa
65 libiconv
66 ] ++ lib.optionals enablePython [ swig4 python ];
67
68 disabledTests = [
69 # require networking:
70 "TestEcho"
71 "TestFind"
72 "gdcmscu-echo-dicomserver"
73 "gdcmscu-find-dicomserver"
74 # seemingly ought to be be disabled when the test data submodule is not present:
75 "TestvtkGDCMImageReader2_3"
76 "TestSCUValidation"
77 # errors because 3 classes not wrapped:
78 "TestWrapPython"
79 ] ++ lib.optionals (stdenv.isAarch64 && stdenv.isLinux) [
80 "TestRescaler2"
81 ];
82
83 checkPhase = ''
84 runHook preCheck
85 ctest --exclude-regex '^(${lib.concatStringsSep "|" disabledTests})$'
86 runHook postCheck
87 '';
88 doCheck = true;
89 # note that when the test data is available to the build via `fetchSubmodules = true`,
90 # a number of additional but much slower tests are enabled
91
92 meta = with lib; {
93 description = "The grassroots cross-platform DICOM implementation";
94 longDescription = ''
95 Grassroots DICOM (GDCM) is an implementation of the DICOM standard designed to be open source so that researchers may access clinical data directly.
96 GDCM includes a file format definition and a network communications protocol, both of which should be extended to provide a full set of tools for a researcher or small medical imaging vendor to interface with an existing medical database.
97 '';
98 homepage = "https://gdcm.sourceforge.net/";
99 license = with licenses; [ bsd3 asl20 ];
100 maintainers = with maintainers; [ tfmoraes ];
101 platforms = platforms.all;
102 };
103}