Skip to content

WIP: Require ITK 6 and request modules as find_package COMPONENTS - #481

Draft
hjmjohnson wants to merge 13 commits into
InsightSoftwareConsortium:mainfrom
hjmjohnson:comp-require-itk6
Draft

WIP: Require ITK 6 and request modules as find_package COMPONENTS#481
hjmjohnson wants to merge 13 commits into
InsightSoftwareConsortium:mainfrom
hjmjohnson:comp-require-itk6

Conversation

@hjmjohnson

@hjmjohnson hjmjohnson commented Sep 12, 2026

Copy link
Copy Markdown
Member

Require ITK 6 and request each example's modules as find_package COMPONENTS,
linking ${ITK_INTERFACE_LIBRARIES}. Supersedes #470.

Stacked on #479 — review the 12 commits from COMP: Require ITK 6 onward.

Why require ITK 6

Every example already links ITK::<Name>Module interface targets, which ITK 5.x does not export. Against ITK 5.4 the build fails with one missing-target error per example (346 in all); requiring ITK 6 stops at the first find_package with a single version error instead.

Examples for ITK 5.x live on the release-5.4 branch, created at b0679d89, the last commit that still builds with ITK 5.x (verified against ITK 5.4.7: 0 failed targets, 346 executables, 370/370 tests).

What the conversion does, and the two rules it follows

Each example's ITK::<Name>Module link targets become find_package components, and the link list becomes ${ITK_INTERFACE_LIBRARIES}:

-find_package(ITK REQUIRED)
+find_package(
+  ITK
+  REQUIRED
+  COMPONENTS
+    ITKImageIO
+    ITKThresholding
+)
 itk_generate_factory_registration()
 target_link_libraries(
   ${PROJECT_NAME}
   PRIVATE
+    ${ITK_INTERFACE_LIBRARIES}
     ITK::ITKImageIO
-    ITK::ITKThresholdingModule
 )

Two rules the script applies, both load-bearing:

  1. Component names are module names, not target names — ITKAnisotropicSmoothing, not ITK::ITKAnisotropicSmoothingModule. Naming a target here stops the configure with No such module.
  2. Factory meta-modules stay explicitly linked (ITKImageIO, ITKMeshIO, ITKTransformIO, ITKFFTImageFilterInit), because linking the meta-module is what enables the generated registration code. ITKVtkGlue and ITKVideoBridgeOpenCV stay explicit links and are deliberately not components: they are conditional, so requiring them would break every VTK-less or OpenCV-less build.

Commits are one per top-level src/ directory, from 12 files in Bridge to 183 in Filtering.

Verification

Built against ITK main with Module_ITKVtkGlue=ON and Python wrapping enabled, then run through the project's own ctest suite:

before after
build 0 failed targets, 365 executables 0 failed targets, 365 executables
tests 200 failures of 558 identical set

0 new failures, 0 newly passing. The conversion is behavior-neutral, which is the intent: it changes how modules are requested, not what gets linked. Spot-checked on one example that the executable links the same 52 ITK libraries, registers the same 24 ImageIO factories, and produces byte-identical output.

pre-commit run --all-files passes, gersemi included.

@github-actions github-actions Bot added the type:Enhancement Improvement of existing methods or implementation label Sep 12, 2026
hjmjohnson and others added 5 commits September 12, 2026 13:38
Python 3.12 removed distutils, so every example guarding its minimum ITK
version with distutils.version.StrictVersion fails at import:

    ModuleNotFoundError: No module named 'distutils'

Compare the dotted version components as a tuple instead, which needs no
import at all and keeps each example's existing minimum.

SegmentBloodVessels and
SegmentBloodVesselsWithMultiScaleHessianBasedMeasure called sys.exit()
in that guard without importing sys; add the import.
Every example links ITK::...Module interface targets, which ITK 5.x does
not export, so against ITK 5.4 configure fails with one missing-target
error per example (346 in all). Requiring ITK 6 stops at the first
find_package with a single version error instead.

Examples for ITK 5.x now live on the release-5.4 branch.
Request the modules the example uses as find_package(ITK COMPONENTS)
and link ${ITK_INTERFACE_LIBRARIES}, the form the ITK 6 migration guide
recommends. The ITKImageIO factory meta-module is both requested and
linked, since linking it is what enables the generated registration.

Component names are module names (ITKAnisotropicSmoothing), not the
ITK::...Module target names.

Supersedes InsightSoftwareConsortium#470.

Co-Authored-By: Bradley Lowekamp <blowekamp@mail.nih.gov>
Move each ITK::<Name>Module link target into find_package(ITK
COMPONENTS <Name>) and link ${ITK_INTERFACE_LIBRARIES}. Factory
meta-modules such as ITKImageIO are requested and still linked, since
linking one enables its registration. ITKVtkGlue and
ITKVideoBridgeOpenCV stay explicit links because they are conditional.

Co-Authored-By: Bradley Lowekamp <blowekamp@mail.nih.gov>
Move each ITK::<Name>Module link target into find_package(ITK
COMPONENTS <Name>) and link ${ITK_INTERFACE_LIBRARIES}. Factory
meta-modules such as ITKImageIO are requested and still linked, since
linking one enables its registration. ITKVtkGlue and
ITKVideoBridgeOpenCV stay explicit links because they are conditional.

Co-Authored-By: Bradley Lowekamp <blowekamp@mail.nih.gov>
hjmjohnson and others added 8 commits September 12, 2026 13:42
Move each ITK::<Name>Module link target into find_package(ITK
COMPONENTS <Name>) and link ${ITK_INTERFACE_LIBRARIES}. Factory
meta-modules such as ITKImageIO are requested and still linked, since
linking one enables its registration. ITKVtkGlue and
ITKVideoBridgeOpenCV stay explicit links because they are conditional.

Co-Authored-By: Bradley Lowekamp <blowekamp@mail.nih.gov>
Move each ITK::<Name>Module link target into find_package(ITK
COMPONENTS <Name>) and link ${ITK_INTERFACE_LIBRARIES}. Factory
meta-modules such as ITKImageIO are requested and still linked, since
linking one enables its registration. ITKVtkGlue and
ITKVideoBridgeOpenCV stay explicit links because they are conditional.

Co-Authored-By: Bradley Lowekamp <blowekamp@mail.nih.gov>
Move each ITK::<Name>Module link target into find_package(ITK
COMPONENTS <Name>) and link ${ITK_INTERFACE_LIBRARIES}. Factory
meta-modules such as ITKImageIO are requested and still linked, since
linking one enables its registration. ITKVtkGlue and
ITKVideoBridgeOpenCV stay explicit links because they are conditional.

Co-Authored-By: Bradley Lowekamp <blowekamp@mail.nih.gov>
Move each ITK::<Name>Module link target into find_package(ITK
COMPONENTS <Name>) and link ${ITK_INTERFACE_LIBRARIES}. Factory
meta-modules such as ITKImageIO are requested and still linked, since
linking one enables its registration. ITKVtkGlue and
ITKVideoBridgeOpenCV stay explicit links because they are conditional.

Co-Authored-By: Bradley Lowekamp <blowekamp@mail.nih.gov>
Move each ITK::<Name>Module link target into find_package(ITK
COMPONENTS <Name>) and link ${ITK_INTERFACE_LIBRARIES}. Factory
meta-modules such as ITKImageIO are requested and still linked, since
linking one enables its registration. ITKVtkGlue and
ITKVideoBridgeOpenCV stay explicit links because they are conditional.

Co-Authored-By: Bradley Lowekamp <blowekamp@mail.nih.gov>
Move each ITK::<Name>Module link target into find_package(ITK
COMPONENTS <Name>) and link ${ITK_INTERFACE_LIBRARIES}. Factory
meta-modules such as ITKImageIO are requested and still linked, since
linking one enables its registration. ITKVtkGlue and
ITKVideoBridgeOpenCV stay explicit links because they are conditional.

Co-Authored-By: Bradley Lowekamp <blowekamp@mail.nih.gov>
Move each ITK::<Name>Module link target into find_package(ITK
COMPONENTS <Name>) and link ${ITK_INTERFACE_LIBRARIES}. Factory
meta-modules such as ITKImageIO are requested and still linked, since
linking one enables its registration. ITKVtkGlue and
ITKVideoBridgeOpenCV stay explicit links because they are conditional.

Co-Authored-By: Bradley Lowekamp <blowekamp@mail.nih.gov>
Move each ITK::<Name>Module link target into find_package(ITK
COMPONENTS <Name>) and link ${ITK_INTERFACE_LIBRARIES}. Factory
meta-modules such as ITKImageIO are requested and still linked, since
linking one enables its registration. ITKVtkGlue and
ITKVideoBridgeOpenCV stay explicit links because they are conditional.

Co-Authored-By: Bradley Lowekamp <blowekamp@mail.nih.gov>
@hjmjohnson hjmjohnson changed the title ENH: Require ITK 6 and request modules as find_package COMPONENTS WIP: Require ITK 6 and request modules as find_package COMPONENTS Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:Enhancement Improvement of existing methods or implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant