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,6 +1257,14 @@ libraries designed for computer vision research and implementation.")
"-DCMAKE_CXX_STANDARD=14"))))) "-DCMAKE_CXX_STANDARD=14")))))
(define-public insight-toolkit (define-public insight-toolkit
;; For information about ITK remote modules, see:
;; https://insightsoftwareconsortium.github.io/ITKWikiArchive/Wiki/ITK/Policy_and_Procedures_for_Adding_Remote_Modules
;; For a remote MODULE, use the commit in
;; 'Modules/Remote/MODULE.remote.cmake'.
;; MorphologicalContourInterpolation is required by itk-snap.
(let* ((module-commit "821bf9b3ef8eaaab10391ed060dc9ca5e4d37b39")
(module-file (git-file-name "ITKMorphologicalContourInterpolation"
module-commit)))
(package (package
(name "insight-toolkit") (name "insight-toolkit")
(version "5.4.4") (version "5.4.4")
@ -1275,14 +1284,15 @@ libraries designed for computer vision research and implementation.")
(build-system cmake-build-system) (build-system cmake-build-system)
(outputs '("out" "python")) (outputs '("out" "python"))
(arguments (arguments
(list #:tests? #f ; tests require network access and external data (list
#:tests? #f ;tests require network access and external data
#:configure-flags #:configure-flags
#~(list "-DITK_USE_GPU=ON" #~(list "-DITK_USE_GPU=ON"
"-DITK_USE_SYSTEM_LIBRARIES=ON" "-DITK_USE_SYSTEM_LIBRARIES=ON"
"-DITK_USE_SYSTEM_CASTXML=ON" "-DITK_USE_SYSTEM_CASTXML=ON"
"-DITK_USE_SYSTEM_SWIG=ON" "-DITK_USE_SYSTEM_SWIG=ON"
(string-append "-DHDF5_DIR=" #$(this-package-input "hdf5") (string-append "-DHDF5_DIR="
"/lib/cmake") #$(this-package-input "hdf5") "/lib/cmake")
"-DBUILD_SHARED_LIBS=ON" "-DBUILD_SHARED_LIBS=ON"
;; Without this flag, there are shared libraries installed ;; Without this flag, there are shared libraries installed
;; in PY_SITE_PACKAGES_PATH/itk instead of #$output/lib and ;; in PY_SITE_PACKAGES_PATH/itk instead of #$output/lib and
@ -1294,18 +1304,22 @@ libraries designed for computer vision research and implementation.")
"-DITK_DYNAMIC_LOADING=ON" "-DITK_DYNAMIC_LOADING=ON"
(let* ((python-version (let* ((python-version
#$(version-major+minor #$(version-major+minor
(package-version (this-package-input "python")))) (package-version
(python-lib-path (this-package-input "python"))))
(string-append #$output:python (python-lib-path (string-append #$output:python
"/lib/python" python-version "/lib/python"
python-version
"/site-packages"))) "/site-packages")))
(string-append "-DPY_SITE_PACKAGES_PATH=" python-lib-path)) (string-append "-DPY_SITE_PACKAGES_PATH="
python-lib-path))
;; Python is not built with Py_LIMITED_API. ;; Python is not built with Py_LIMITED_API.
"-DITK_USE_PYTHON_LIMITED_API=OFF" "-DITK_USE_PYTHON_LIMITED_API=OFF"
"-DModule_MorphologicalContourInterpolation=ON"
"-DCMAKE_CXX_STANDARD=17" "-DCMAKE_CXX_STANDARD=17"
"-DBUILD_TESTING=OFF") "-DBUILD_TESTING=OFF")
#:phases #~(modify-phases %standard-phases #:phases
#~(modify-phases %standard-phases
(add-after 'unpack 'do-not-tune (add-after 'unpack 'do-not-tune
(lambda _ (lambda _
(substitute* "CMake/ITKSetStandardCompilerFlags.cmake" (substitute* "CMake/ITKSetStandardCompilerFlags.cmake"
@ -1314,7 +1328,8 @@ libraries designed for computer vision research and implementation.")
(add-after 'unpack 'ignore-warnings (add-after 'unpack 'ignore-warnings
(lambda _ (lambda _
(substitute* "Wrapping/Generators/Python/CMakeLists.txt" (substitute* "Wrapping/Generators/Python/CMakeLists.txt"
(("-Werror") "")))) (("-Werror")
""))))
(add-after 'unpack 'exclude-gtest-target (add-after 'unpack 'exclude-gtest-target
(lambda _ (lambda _
;; Prevent ITKGoogleTest from being added to ;; Prevent ITKGoogleTest from being added to
@ -1327,9 +1342,19 @@ libraries designed for computer vision research and implementation.")
;; <https://codeberg.org/guix/guix/issues/776>. ;; <https://codeberg.org/guix/guix/issues/776>.
;; <https://github.com/microsoft/vcpkg/pull/27187> ;; <https://github.com/microsoft/vcpkg/pull/27187>
(substitute* "Modules/ThirdParty/GoogleTest/itk-module.cmake" (substitute* "Modules/ThirdParty/GoogleTest/itk-module.cmake"
(("DEPENDS") "DEPENDS\n EXCLUDE_FROM_DEFAULT"))))))) (("DEPENDS")
(inputs "DEPENDS\n EXCLUDE_FROM_DEFAULT"))))
(list eigen (add-after 'unpack 'prepare-remote-modules
(lambda _
;; ITK module MorphologicalContourInterpolation
;; is for ITK-SNAP.
(symlink #$(this-package-native-input module-file)
"Modules/Remote/MorphologicalContourInterpolation")
(delete-file
(string-append
"Modules/Remote/"
"MorphologicalContourInterpolation.remote.cmake")))))))
(inputs (list eigen
expat expat
fftw fftw
fftwf fftwf
@ -1344,7 +1369,24 @@ libraries designed for computer vision research and implementation.")
vxl-1 vxl-1
zlib)) zlib))
(native-inputs (native-inputs
(list castxml gcc-13 git-minimal pkg-config swig-next which)) (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
@ -1353,7 +1395,8 @@ libraries designed for computer vision research and implementation.")
(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)