Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / development / libraries / itk / generic.nix
blob3a6b2afee0d956809f0bd430435eb2ea5e9fce84
1 { version, rev, sourceSha256 }:
3 { lib, stdenv, fetchFromGitHub, cmake, makeWrapper
4 , pkg-config, libX11, libuuid, xz, vtk, Cocoa }:
6 let
7   itkGenericLabelInterpolatorSrc = fetchFromGitHub {
8     owner = "InsightSoftwareConsortium";
9     repo = "ITKGenericLabelInterpolator";
10     rev = "2f3768110ffe160c00c533a1450a49a16f4452d9";
11     hash = "sha256-Cm3jg14MMnbr/sP+gqR2Rh25xJjoRvpmY/jP/DKH978=";
12   };
14   itkAdaptiveDenoisingSrc = fetchFromGitHub {
15     owner = "ntustison";
16     repo = "ITKAdaptiveDenoising";
17     rev = "24825c8d246e941334f47968553f0ae388851f0c";
18     hash = "sha256-deJbza36c0Ohf9oKpO2T4po37pkyI+2wCSeGL4r17Go=";
19   };
21   itkSimpleITKFiltersSrc = fetchFromGitHub {
22     owner = "InsightSoftwareConsortium";
23     repo = "ITKSimpleITKFilters";
24     rev = "bb896868fc6480835495d0da4356d5db009592a6";
25     hash = "sha256-MfaIA0xxA/pzUBSwnAevr17iR23Bo5iQO2cSyknS3o4=";
26   };
29 stdenv.mkDerivation {
30   pname = "itk";
31   inherit version;
33   src = fetchFromGitHub {
34     owner = "InsightSoftwareConsortium";
35     repo = "ITK";
36     inherit rev;
37     sha256 = sourceSha256;
38   };
40   postPatch = ''
41     substituteInPlace CMake/ITKSetStandardCompilerFlags.cmake  \
42       --replace "-march=corei7" ""  \
43       --replace "-mtune=native" ""
44     substituteInPlace Modules/ThirdParty/GDCM/src/gdcm/Utilities/gdcmopenjpeg/src/lib/openjp2/libopenjp2.pc.cmake.in  \
45       --replace "@OPENJPEG_INSTALL_LIB_DIR@" "@OPENJPEG_INSTALL_FULL_LIB_DIR@"
46     ln -sr ${itkGenericLabelInterpolatorSrc} Modules/External/ITKGenericLabelInterpolator
47     ln -sr ${itkAdaptiveDenoisingSrc} Modules/External/ITKAdaptiveDenoising
48     ln -sr ${itkSimpleITKFiltersSrc} Modules/External/ITKSimpleITKFilters
49   '';
51   cmakeFlags = [
52     "-DBUILD_EXAMPLES=OFF"
53     "-DBUILD_SHARED_LIBS=ON"
54     "-DITK_FORBID_DOWNLOADS=ON"
55     "-DModule_ITKMINC=ON"
56     "-DModule_ITKIOMINC=ON"
57     "-DModule_ITKIOTransformMINC=ON"
58     "-DModule_SimpleITKFilters=ON"
59     "-DModule_ITKVtkGlue=ON"
60     "-DModule_ITKReview=ON"
61     "-DModule_MGHIO=ON"
62     "-DModule_AdaptiveDenoising=ON"
63     "-DModule_GenericLabelInterpolator=ON"
64   ];
66   nativeBuildInputs = [ cmake xz makeWrapper ];
67   buildInputs = [ libX11 libuuid vtk ] ++ lib.optionals stdenv.isDarwin [ Cocoa ];
68   # Due to ITKVtkGlue=ON and the additional dependencies needed to configure VTK 9
69   # (specifically libGL and libX11 on Linux),
70   # it's now seemingly necessary for packages that configure ITK to
71   # also include configuration deps of VTK, even if VTK is not required or available.
72   # These deps were propagated from VTK 9 in https://github.com/NixOS/nixpkgs/pull/206935,
73   # so we simply propagate them again from ITK.
74   # This admittedly is a hack and seems like an issue with VTK 9's CMake configuration.
75   propagatedBuildInputs = vtk.propagatedBuildInputs;
77   postInstall = ''
78     wrapProgram "$out/bin/h5c++" --prefix PATH ":" "${pkg-config}/bin"
79   '';
81   meta = {
82     description = "Insight Segmentation and Registration Toolkit";
83     homepage = "https://www.itk.org";
84     license = lib.licenses.asl20;
85     maintainers = with lib.maintainers; [viric];
86   };