WIP: Require ITK 6 and request modules as find_package COMPONENTS - #481
hjmjohnson wants to merge 12 commits into
Conversation
18403e0 to
c76bf1d
Compare
c76bf1d to
153b8ef
Compare
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.
Name the ITK modules behind each example's includes and link targets as find_package COMPONENTS, so configure fails with "No such module" when a module is missing rather than with a missing target at generate time. Link lines are unchanged: each example keeps its explicit ITK::<Name>Module targets, which show a reader which module provides which class. Follows the COMPONENTS approach proposed in InsightSoftwareConsortium#470. Co-Authored-By: Bradley Lowekamp <blowekamp@mail.nih.gov>
Name the ITK modules behind each example's includes and link targets as find_package COMPONENTS, so configure fails with "No such module" when a module is missing rather than with a missing target at generate time. Link lines are unchanged: each example keeps its explicit ITK::<Name>Module targets, which show a reader which module provides which class. Follows the COMPONENTS approach proposed in InsightSoftwareConsortium#470. Co-Authored-By: Bradley Lowekamp <blowekamp@mail.nih.gov>
Name the ITK modules behind each example's includes and link targets as find_package COMPONENTS, so configure fails with "No such module" when a module is missing rather than with a missing target at generate time. Link lines are unchanged: each example keeps its explicit ITK::<Name>Module targets, which show a reader which module provides which class. Follows the COMPONENTS approach proposed in InsightSoftwareConsortium#470. Co-Authored-By: Bradley Lowekamp <blowekamp@mail.nih.gov>
Name the ITK modules behind each example's includes and link targets as find_package COMPONENTS, so configure fails with "No such module" when a module is missing rather than with a missing target at generate time. Link lines are unchanged: each example keeps its explicit ITK::<Name>Module targets, which show a reader which module provides which class. Follows the COMPONENTS approach proposed in InsightSoftwareConsortium#470. Co-Authored-By: Bradley Lowekamp <blowekamp@mail.nih.gov>
Name the ITK modules behind each example's includes and link targets as find_package COMPONENTS, so configure fails with "No such module" when a module is missing rather than with a missing target at generate time. Link lines are unchanged: each example keeps its explicit ITK::<Name>Module targets, which show a reader which module provides which class. Follows the COMPONENTS approach proposed in InsightSoftwareConsortium#470. Co-Authored-By: Bradley Lowekamp <blowekamp@mail.nih.gov>
Name the ITK modules behind each example's includes and link targets as find_package COMPONENTS, so configure fails with "No such module" when a module is missing rather than with a missing target at generate time. Link lines are unchanged: each example keeps its explicit ITK::<Name>Module targets, which show a reader which module provides which class. Follows the COMPONENTS approach proposed in InsightSoftwareConsortium#470. Co-Authored-By: Bradley Lowekamp <blowekamp@mail.nih.gov>
Name the ITK modules behind each example's includes and link targets as find_package COMPONENTS, so configure fails with "No such module" when a module is missing rather than with a missing target at generate time. Link lines are unchanged: each example keeps its explicit ITK::<Name>Module targets, which show a reader which module provides which class. Follows the COMPONENTS approach proposed in InsightSoftwareConsortium#470. Co-Authored-By: Bradley Lowekamp <blowekamp@mail.nih.gov>
Name the ITK modules behind each example's includes and link targets as find_package COMPONENTS, so configure fails with "No such module" when a module is missing rather than with a missing target at generate time. Link lines are unchanged: each example keeps its explicit ITK::<Name>Module targets, which show a reader which module provides which class. Follows the COMPONENTS approach proposed in InsightSoftwareConsortium#470. Co-Authored-By: Bradley Lowekamp <blowekamp@mail.nih.gov>
Name the ITK modules behind each example's includes and link targets as find_package COMPONENTS, so configure fails with "No such module" when a module is missing rather than with a missing target at generate time. Link lines are unchanged: each example keeps its explicit ITK::<Name>Module targets, which show a reader which module provides which class. Follows the COMPONENTS approach proposed in InsightSoftwareConsortium#470. Co-Authored-By: Bradley Lowekamp <blowekamp@mail.nih.gov>
Name the ITK modules behind each example's includes and link targets as find_package COMPONENTS, so configure fails with "No such module" when a module is missing rather than with a missing target at generate time. Link lines are unchanged: each example keeps its explicit ITK::<Name>Module targets, which show a reader which module provides which class. Follows the COMPONENTS approach proposed in InsightSoftwareConsortium#470. Co-Authored-By: Bradley Lowekamp <blowekamp@mail.nih.gov>
153b8ef to
3e619b9
Compare
|
What was the prior behavior here for these examples? Was every example just linked to everything in ITK and all ImageIO's loaded? It appears a motivation for using only the needed ImageIO is to reduce the binary size. I would be interested in how the size of a share library build is by comparison to the other options. I think finding the "ImageIO" package is the best approach, which is now done here. |
This is quite possible. The examples' build directory was big: 30-40 GB with statically built libraries. |
|
Closing: once #479, #482, and #488 are in, requesting modules as COMPONENTS shows no measured benefit, so there is nothing left worth merging here.
All ImageIOs, not all of ITK. Each example links explicit
With Measurements (static ITK main, macOS arm64)One standalone example (
Across the aggregate build, The only size win is narrowing to specific formats (e.g. A shared-library comparison has not been measured. |
ITK's VtkGlue requires VTK 9.1, so the VTK_VERSION VERSION_LESS "8.90.0" branches can never be taken. Drop the VTK_USE_FILE includes and the _vtk_prefix component prefix, and call vtk_module_autoinit unconditionally. Suggested in review of #481.
Request the ITK modules each example uses as
find_packageCOMPONENTS.Link lines are unchanged: each example keeps its explicit
ITK::<Name>Moduletargets.Stacked on #479 and #482 — review the last 10 commits.
What this buys
Components are derived from the ITK headers each example includes, resolved through an index of 3282 headers across ITK's 167 modules. Naming them means a missing or disabled module fails at configure time with
No such module: X, rather than as a missing target at generate time.Link lines keep the explicit module targets rather than
${ITK_INTERFACE_LIBRARIES}: these examples are teaching material, andITK::ITKThresholdingModuleon the link line tells a reader which module provides the class the example demonstrates.Why the components are not narrowed to specific IO formats
Requesting the exact format an example reads (
ITKIOPNGinstead of theITKImageIOmeta-module) shrinks the built examples from 5.26 GB to 0.72 GB, because only the requested factory is registered.That is not usable here yet:
itk_generate_factory_registration()records the generated header's include directory on the sharedITK::ITKImageIOtarget, so in an aggregate build the last example configured wins and the others compile against its registration header. Measured on this repository, per-format narrowing produced 62 new test failures for that reason. Reported as InsightSoftwareConsortium/ITK#6860; once registration attaches per target, the narrowing becomes available.Six examples still name a format module — the GDCM, TIFF, and factory-registration examples — because they include
itkGDCMImageIO.h,itkTIFFImageIO.h, oritkPNGImageIOFactory.hdirectly and need it on the include path.Verification
Built against ITK
mainwithModule_ITKVtkGlue=ONand Python wrapping enabled:No new failures and none fixed. The two remaining failures are unrelated to this change:
ConvolveImageWithKernelTestPythonneedsmatplotlib, andComputeFFTInOneDimensionPhaseBaselineComparisonPythonfails a baseline image comparison.