From 0e169cf0cc767c3c10284835f645198d89f83f51 Mon Sep 17 00:00:00 2001 From: Ben Darwin Date: Sun, 5 Nov 2023 21:42:59 -0500 Subject: itk: unvendor some of the dependencies Unvendored GDCM, MINC, and several common libraries (under the omnibus but incomplete ITK_USE_SYSTEM_LIBRARIES). We didn't unvendor Eigen, Gtest, or VXL due to downstream compilation errors, but at least the first two of these are less of a security risk. Some other libraries such as NIfTI, GIfTI, etc., seemingly can't be unvendored via ITK_USE_SYSTEM_<...>, and others such as TBB aren't enabled by default. --- pkgs/development/libraries/itk/generic.nix | 43 ++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 11 deletions(-) (limited to 'pkgs') diff --git a/pkgs/development/libraries/itk/generic.nix b/pkgs/development/libraries/itk/generic.nix index 3a6b2afee0d95..e2db993707e21 100644 --- a/pkgs/development/libraries/itk/generic.nix +++ b/pkgs/development/libraries/itk/generic.nix @@ -1,7 +1,8 @@ { 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"; -- cgit 1.4.1 From dc16ee70143744bd35e5ac7dba03bb729f19e5bd Mon Sep 17 00:00:00 2001 From: Ben Darwin Date: Wed, 15 Nov 2023 12:12:41 -0500 Subject: gdcm: disable failing test on Aarch64 --- pkgs/development/libraries/gdcm/default.nix | 2 ++ 1 file changed, 2 insertions(+) (limited to 'pkgs') diff --git a/pkgs/development/libraries/gdcm/default.nix b/pkgs/development/libraries/gdcm/default.nix index c186ffb4a1353..a064a31f3ca20 100644 --- a/pkgs/development/libraries/gdcm/default.nix +++ b/pkgs/development/libraries/gdcm/default.nix @@ -76,6 +76,8 @@ stdenv.mkDerivation rec { "TestSCUValidation" # errors because 3 classes not wrapped: "TestWrapPython" + ] ++ lib.optionals (stdenv.isAarch64 && stdenv.isLinux) [ + "TestRescaler2" ]; checkPhase = '' -- cgit 1.4.1