Unverified Commit dba8a3ef authored by Mario Rodas's avatar Mario Rodas Committed by GitHub
Browse files

Merge pull request #265927 from bcdarwin/itk-unvendor

itk: unvendor some of the dependencies
parents b56dc6be dc16ee70
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -76,6 +76,8 @@ stdenv.mkDerivation rec {
    "TestSCUValidation"
    # errors because 3 classes not wrapped:
    "TestWrapPython"
  ] ++ lib.optionals (stdenv.isAarch64 && stdenv.isLinux) [
    "TestRescaler2"
  ];

  checkPhase = ''
+32 −11
Original line number Diff line number Diff line
{ version, rev, sourceSha256 }:

{ lib, stdenv, fetchFromGitHub, cmake, makeWrapper
, pkg-config, libX11, libuuid, xz, vtk, Cocoa }:
{ lib, stdenv, fetchFromGitHub, cmake
, expat, fftw, gdcm, hdf5-cpp, libjpeg, libminc, libtiff, libpng
, libX11, libuuid, xz, vtk, zlib, Cocoa }:

let
  itkGenericLabelInterpolatorSrc = fetchFromGitHub {
@@ -41,8 +42,6 @@ stdenv.mkDerivation {
    substituteInPlace CMake/ITKSetStandardCompilerFlags.cmake  \
      --replace "-march=corei7" ""  \
      --replace "-mtune=native" ""
    substituteInPlace Modules/ThirdParty/GDCM/src/gdcm/Utilities/gdcmopenjpeg/src/lib/openjp2/libopenjp2.pc.cmake.in  \
      --replace "@OPENJPEG_INSTALL_LIB_DIR@" "@OPENJPEG_INSTALL_FULL_LIB_DIR@"
    ln -sr ${itkGenericLabelInterpolatorSrc} Modules/External/ITKGenericLabelInterpolator
    ln -sr ${itkAdaptiveDenoisingSrc} Modules/External/ITKAdaptiveDenoising
    ln -sr ${itkSimpleITKFiltersSrc} Modules/External/ITKSimpleITKFilters
@@ -52,6 +51,15 @@ stdenv.mkDerivation {
    "-DBUILD_EXAMPLES=OFF"
    "-DBUILD_SHARED_LIBS=ON"
    "-DITK_FORBID_DOWNLOADS=ON"
    "-DITK_USE_SYSTEM_LIBRARIES=ON"  # finds common libraries e.g. hdf5, libpng, libtiff, zlib, but not GDCM, NIFTI, MINC, etc.
    # note ITK_USE_SYSTEM_EIGEN, part of ITK_USE_SYSTEM_LIBRARIES,
    # causes "...-itk-5.2.1/include/ITK-5.2/itkSymmetricEigenAnalysis.h:23:31: fatal error: Eigen/Eigenvalues: No such file or directory"
    # when compiling c3d, but maybe an ITK 5.2/eigen version issue:
    "-DITK_USE_SYSTEM_EIGEN=OFF"
    "-DITK_USE_SYSTEM_GOOGLETEST=OFF"  # ANTs build failure due to https://github.com/ANTsX/ANTs/issues/1489
    "-DITK_USE_SYSTEM_GDCM=ON"
    "-DITK_USE_SYSTEM_MINC=ON"
    "-DLIBMINC_DIR=${libminc}/lib/cmake"
    "-DModule_ITKMINC=ON"
    "-DModule_ITKIOMINC=ON"
    "-DModule_ITKIOTransformMINC=ON"
@@ -63,8 +71,12 @@ stdenv.mkDerivation {
    "-DModule_GenericLabelInterpolator=ON"
  ];

  nativeBuildInputs = [ cmake xz makeWrapper ];
  buildInputs = [ libX11 libuuid vtk ] ++ lib.optionals stdenv.isDarwin [ Cocoa ];
  nativeBuildInputs = [ cmake xz ];
  buildInputs = [
    libX11
    libuuid
    vtk
  ] ++ lib.optionals stdenv.isDarwin [ Cocoa ];
  # Due to ITKVtkGlue=ON and the additional dependencies needed to configure VTK 9
  # (specifically libGL and libX11 on Linux),
  # it's now seemingly necessary for packages that configure ITK to
@@ -72,11 +84,20 @@ stdenv.mkDerivation {
  # These deps were propagated from VTK 9 in https://github.com/NixOS/nixpkgs/pull/206935,
  # so we simply propagate them again from ITK.
  # This admittedly is a hack and seems like an issue with VTK 9's CMake configuration.
  propagatedBuildInputs = vtk.propagatedBuildInputs;

  postInstall = ''
    wrapProgram "$out/bin/h5c++" --prefix PATH ":" "${pkg-config}/bin"
  '';
  propagatedBuildInputs = [
    # The dependencies we've un-vendored from ITK, such as GDCM, must be propagated,
    # otherwise other software built against ITK fails to configure since ITK headers
    # refer to these previously vendored libraries:
    expat
    fftw
    gdcm
    hdf5-cpp
    libjpeg
    libminc
    libpng
    libtiff
    zlib
  ] ++ vtk.propagatedBuildInputs;

  meta = {
    description = "Insight Segmentation and Registration Toolkit";