gnu: insight-toolkit: Include remote module for ITK-SNAP.

* gnu/packages/image-processing.scm (insight-toolkit)[arguments]
<#:configure-flags>: Add "-DModule_MorphologicalContourInterpolation=ON".
<#:phases>: Add phase 'prepare-remote-modules.
[native-inputs]: Add origin for MorphologicalContourInterpolation checkout.

Change-Id: I441f250d42f5ac1077c72a3c15281dd327264f3b
Co-authored-by: Andreas Enge <andreas@enge.fr>
Signed-off-by: Andreas Enge <andreas@enge.fr>
This commit is contained in:
Jake Forster 2025-07-26 00:46:45 +09:30 committed by Andreas Enge
parent 2b7aefcf2c
commit 61a1741f38
No known key found for this signature in database
GPG key ID: F7D5C9BF765C61E3

View file

@ -26,6 +26,7 @@
;;; Copyright © 2024 Nicolas Graves <ngraves@ngraves.fr> ;;; Copyright © 2024 Nicolas Graves <ngraves@ngraves.fr>
;;; Copyright © 2025 Jake Forster <jakecameron.forster@gmail.com> ;;; Copyright © 2025 Jake Forster <jakecameron.forster@gmail.com>
;;; Copyright © 2025 Anderson Torres <anderson.torres.8519@gmail.com> ;;; Copyright © 2025 Anderson Torres <anderson.torres.8519@gmail.com>
;;; Copyright © 2025 Andreas Enge <andreas@enge.fr>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -1256,104 +1257,146 @@ libraries designed for computer vision research and implementation.")
"-DCMAKE_CXX_STANDARD=14"))))) "-DCMAKE_CXX_STANDARD=14")))))
(define-public insight-toolkit (define-public insight-toolkit
(package ;; For information about ITK remote modules, see:
(name "insight-toolkit") ;; https://insightsoftwareconsortium.github.io/ITKWikiArchive/Wiki/ITK/Policy_and_Procedures_for_Adding_Remote_Modules
(version "5.4.4") ;; For a remote MODULE, use the commit in
(source ;; 'Modules/Remote/MODULE.remote.cmake'.
(origin ;; MorphologicalContourInterpolation is required by itk-snap.
(method git-fetch) (let* ((module-commit "821bf9b3ef8eaaab10391ed060dc9ca5e4d37b39")
(uri (git-reference (module-file (git-file-name "ITKMorphologicalContourInterpolation"
(url "https://github.com/InsightSoftwareConsortium/ITK") module-commit)))
(commit (string-append "v" version)))) (package
(file-name (git-file-name name version)) (name "insight-toolkit")
(sha256 (version "5.4.4")
(base32 "1l5rby8jj8726k380aivycmhn56cz56mr9k3r56c8hkkrfwwng50")) (source
;; This patch is required to build with both ITK_USE_GPU=ON and (origin
;; ITK_WRAP_PYTHON=ON. (method git-fetch)
;; <https://github.com/InsightSoftwareConsortium/ITK/pull/4842> (uri (git-reference
(patches (search-patches "insight-toolkit-fix-build.patch")))) (url "https://github.com/InsightSoftwareConsortium/ITK")
(build-system cmake-build-system) (commit (string-append "v" version))))
(outputs '("out" "python")) (file-name (git-file-name name version))
(arguments (sha256
(list #:tests? #f ; tests require network access and external data (base32 "1l5rby8jj8726k380aivycmhn56cz56mr9k3r56c8hkkrfwwng50"))
#:configure-flags ;; This patch is required to build with both ITK_USE_GPU=ON and
#~(list "-DITK_USE_GPU=ON" ;; ITK_WRAP_PYTHON=ON.
"-DITK_USE_SYSTEM_LIBRARIES=ON" ;; <https://github.com/InsightSoftwareConsortium/ITK/pull/4842>
"-DITK_USE_SYSTEM_CASTXML=ON" (patches (search-patches "insight-toolkit-fix-build.patch"))))
"-DITK_USE_SYSTEM_SWIG=ON" (build-system cmake-build-system)
(string-append "-DHDF5_DIR=" #$(this-package-input "hdf5") (outputs '("out" "python"))
"/lib/cmake") (arguments
"-DBUILD_SHARED_LIBS=ON" (list
;; Without this flag, there are shared libraries installed #:tests? #f ;tests require network access and external data
;; in PY_SITE_PACKAGES_PATH/itk instead of #$output/lib and #:configure-flags
;; RUNPATHs contain the *build directory* of #~(list "-DITK_USE_GPU=ON"
;; PY_SITE_PACKAGES_PATH/itk. "-DITK_USE_SYSTEM_LIBRARIES=ON"
"-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON" "-DITK_USE_SYSTEM_CASTXML=ON"
"-DITK_WRAPPING=ON" "-DITK_USE_SYSTEM_SWIG=ON"
"-DITK_WRAP_PYTHON=ON" (string-append "-DHDF5_DIR="
"-DITK_DYNAMIC_LOADING=ON" #$(this-package-input "hdf5") "/lib/cmake")
(let* ((python-version "-DBUILD_SHARED_LIBS=ON"
#$(version-major+minor ;; Without this flag, there are shared libraries installed
(package-version (this-package-input "python")))) ;; in PY_SITE_PACKAGES_PATH/itk instead of #$output/lib and
(python-lib-path ;; RUNPATHs contain the *build directory* of
(string-append #$output:python ;; PY_SITE_PACKAGES_PATH/itk.
"/lib/python" python-version "-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON"
"/site-packages"))) "-DITK_WRAPPING=ON"
(string-append "-DPY_SITE_PACKAGES_PATH=" python-lib-path)) "-DITK_WRAP_PYTHON=ON"
;; Python is not built with Py_LIMITED_API. "-DITK_DYNAMIC_LOADING=ON"
"-DITK_USE_PYTHON_LIMITED_API=OFF" (let* ((python-version
"-DCMAKE_CXX_STANDARD=17" #$(version-major+minor
"-DBUILD_TESTING=OFF") (package-version
(this-package-input "python"))))
(python-lib-path (string-append #$output:python
"/lib/python"
python-version
"/site-packages")))
(string-append "-DPY_SITE_PACKAGES_PATH="
python-lib-path))
;; Python is not built with Py_LIMITED_API.
"-DITK_USE_PYTHON_LIMITED_API=OFF"
"-DModule_MorphologicalContourInterpolation=ON"
"-DCMAKE_CXX_STANDARD=17"
"-DBUILD_TESTING=OFF")
#:phases #~(modify-phases %standard-phases #:phases
(add-after 'unpack 'do-not-tune #~(modify-phases %standard-phases
(lambda _ (add-after 'unpack 'do-not-tune
(substitute* "CMake/ITKSetStandardCompilerFlags.cmake" (lambda _
(("-mtune=native") (substitute* "CMake/ITKSetStandardCompilerFlags.cmake"
"")))) (("-mtune=native")
(add-after 'unpack 'ignore-warnings ""))))
(lambda _ (add-after 'unpack 'ignore-warnings
(substitute* "Wrapping/Generators/Python/CMakeLists.txt" (lambda _
(("-Werror") "")))) (substitute* "Wrapping/Generators/Python/CMakeLists.txt"
(add-after 'unpack 'exclude-gtest-target (("-Werror")
(lambda _ ""))))
;; Prevent ITKGoogleTest from being added to (add-after 'unpack 'exclude-gtest-target
;; ITK_MODULES_ENABLED in the installed (lambda _
;; ITKConfig.cmake, which in turn prevents ;; Prevent ITKGoogleTest from being added to
;; 'GTest::GTest' from being added to the ;; ITK_MODULES_ENABLED in the installed
;; ITK_LIBRARIES variable. This is necessary ;; ITKConfig.cmake, which in turn prevents
;; because projects that use ITK fail to configure ;; 'GTest::GTest' from being added to the
;; otherwise. Fixes ;; ITK_LIBRARIES variable. This is necessary
;; <https://codeberg.org/guix/guix/issues/776>. ;; because projects that use ITK fail to configure
;; <https://github.com/microsoft/vcpkg/pull/27187> ;; otherwise. Fixes
(substitute* "Modules/ThirdParty/GoogleTest/itk-module.cmake" ;; <https://codeberg.org/guix/guix/issues/776>.
(("DEPENDS") "DEPENDS\n EXCLUDE_FROM_DEFAULT"))))))) ;; <https://github.com/microsoft/vcpkg/pull/27187>
(inputs (substitute* "Modules/ThirdParty/GoogleTest/itk-module.cmake"
(list eigen (("DEPENDS")
expat "DEPENDS\n EXCLUDE_FROM_DEFAULT"))))
fftw (add-after 'unpack 'prepare-remote-modules
fftwf (lambda _
hdf5 ;; ITK module MorphologicalContourInterpolation
libjpeg-turbo ;; is for ITK-SNAP.
libpng (symlink #$(this-package-native-input module-file)
libtiff "Modules/Remote/MorphologicalContourInterpolation")
mesa-opencl (delete-file
perl (string-append
python "Modules/Remote/"
tbb "MorphologicalContourInterpolation.remote.cmake")))))))
vxl-1 (inputs (list eigen
zlib)) expat
(native-inputs fftw
(list castxml gcc-13 git-minimal pkg-config swig-next which)) fftwf
hdf5
libjpeg-turbo
libpng
libtiff
mesa-opencl
perl
python
tbb
vxl-1
zlib))
(native-inputs
(list castxml
gcc-13
git-minimal
pkg-config
swig-next
which
(origin
(method git-fetch)
(uri
(git-reference
(url (string-append
"https://github.com/KitwareMedical/"
"ITKMorphologicalContourInterpolation"))
(commit module-commit)))
(file-name module-file)
(sha256
(base32
"00myhgvlk3n062i8bnknz1d10zkv3jlvs7f4jnk24727gd4v2n4i")))))
;; The 'CMake/ITKSetStandardCompilerFlags.cmake' file normally sets ;; The 'CMake/ITKSetStandardCompilerFlags.cmake' file normally sets
;; '-mtune=native -march=corei7', suggesting there's something to be ;; '-mtune=native -march=corei7', suggesting there's something to be
;; gained from CPU-specific optimizations. ;; gained from CPU-specific optimizations.
(properties '((tunable? . #t))) (properties '((tunable? . #t)))
(home-page "https://github.com/InsightSoftwareConsortium/ITK/") (home-page "https://github.com/InsightSoftwareConsortium/ITK/")
(synopsis "Scientific image processing, segmentation and registration") (synopsis "Scientific image processing, segmentation and registration")
(description "The Insight Toolkit (ITK) is a toolkit for N-dimensional (description
"The Insight Toolkit (ITK) is a toolkit for N-dimensional
scientific image processing, segmentation, and registration. Segmentation is scientific image processing, segmentation, and registration. Segmentation is
the process of identifying and classifying data found in a digitally sampled the process of identifying and classifying data found in a digitally sampled
representation. Typically the sampled representation is an image acquired representation. Typically the sampled representation is an image acquired
@ -1361,7 +1404,7 @@ from such medical instrumentation as CT or MRI scanners. Registration is the
task of aligning or developing correspondences between data. For example, in task of aligning or developing correspondences between data. For example, in
the medical environment, a CT scan may be aligned with a MRI scan in order to the medical environment, a CT scan may be aligned with a MRI scan in order to
combine the information contained in both.") combine the information contained in both.")
(license license:asl2.0))) (license license:asl2.0))))
(define-public insight-toolkit-4 (define-public insight-toolkit-4
(package (inherit insight-toolkit) (package (inherit insight-toolkit)