How to slim down ITK install based on required functions?

Hi
I am trying to build ITK WITHOUT any of the IO modules. I cant seem to figure out the required cmake switches to do this.

Lets say I only need registration functions:
-DITKGroup_Registration:BOOL=ON
-DITK_BUILD_DEFAULT_MODULES:BOOL=OFF \

This still pulls in:
– Enabled ITKMetaIO, needed by [ITKSpatialObjects].
which then pulls in all the IO modules (zlib/etc).

ITKSpatialObjects is required by ITKRegistrationCommon.

Does this mean there is no way to have an ITK build without the IO modules?

Ashish

If you set BUILD_TESTING to OFF, that will greatly reduce dependent IO modules, as tests use a lot of IOs.

@dzenanz - thanks for the quick reply.

I had that, didnt seem like it mattered for the transitive closure of dependencies I listed above.

I tried this:
-DBUILD_UTILITIES:BOOL=OFF
-DBUILD_DOCUMENTATION:BOOL=OFF
-DBUILD_EXAMPLES:BOOL=OFF
-DBUILD_TESTING:BOOL=OFF
-DITK_BUILD_DEFAULT_MODULES:BOOL=OFF
-DITK_USE_GPU:BOOL=OFF
-DITKGroup_Compatibility:BOOL=ON
-DITKGroup_Core:BOOL=OFF
-DITKGroup_Filtering:BOOL=OFF
-DITKGroup_Numerics:BOOL=OFF
-DITKGroup_Registration:BOOL=ON
-DITKGroup_Segmentation:BOOL=OFF
-DModule_ITKTestKernel:BOOL=OFF
-DModule_ITKMetaIO:BOOL=OFF

But it still resulted in the IO libs/GPU libs getting pulled in.

This might not be necessary. Is that right @Stephen_Aylward?

MetaIO needs zlib, and common IO stuff such as imageIObase, but it should not require all the IO modules (NRRD, nifti, HDF5, etc).

@dzenanz - yes, you are right. For the config I listed, only ZLIB gets pulled, not the others.

I am still trying to work backwards from my list of functions to modules to see the slimmest possible ITK I can have. Do you have any suggestions for a rigorous process to follow for this? e.g ITKGroup_Core seems like something I HAVE to enable, which results in:
– Enabled ITKTestKernel, needed by [ITKGroup_Core].
Which then results in all the other IO’s getting pulled in:
– Enabled ITKIOJPEG, needed by [ITKTestKernel].
– Enabled ITKIOBMP, needed by [ITKTestKernel].
etc…

The entire groups is not necessary. In fact, you could disable it and rely on module interdependencies to only bring in the required ones. That will be ITKCommon and maybe some others, but almost certainly not ITKTestKernel, which is usually only needed by tests. ITKTestKernel brings in most IOs.

Here’s the process I am following now:

  1. Look for headers used, e.g
    find sources/ITK/ -name itkOptimizer.h
    sources/ITK/Modules/Numerics/Optimizers/include/itkOptimizer.h
  2. Use -DModule_ITKOptimizers to pick Optimizers/ dir or -DITK_Group_Numerics to pick Numerics dir

Is that the right approach? Appears to work for the above example.

  1. But in the result, e.g sources/ITK/Modules/Registration/PDEDeformable. Choosing -DModule_ITKPDEDeformable to pick the module results in:

Manually-specified variables were not used by the project:
Module_ITKPDEDeformable

And the required header is missing in the install.
So I am now using DITKGroup_Registration instead…

You could/should use WhatModulesITK.py. And instead of putting them in your find_package's components list in your CMakeLists, you enable them in your ITK compile configuration.

1 Like

Thank you @dzenanz for the helpful replies, I am all set.

1 Like

For posterity, what configuration parameters you ended up with?

For my needs, I ended with:
-DBUILD_DOCUMENTATION:BOOL=OFF
-DBUILD_EXAMPLES:BOOL=OFF
-DBUILD_TESTING:BOOL=OFF
-DITK_BUILD_DEFAULT_MODULES:BOOL=OFF
-DITKGroup_Compatibility:BOOL=ON
-DITKGroup_Core:BOOL=OFF
-DITKGroup_Registration:BOOL=ON
-DModule_ITKImageFeature:BOOL=ON
-DModule_ITKLabelMap:BOOL=ON
-DModule_ITKOptimizers:BOOL=ON
-DModule_ITKTestKernel:BOOL=OFF
-DModule_ITKTransform:BOOL=ON

I am yet to explore the need for Compatibility.
And I was unable to narrow down Group_Registration down to one of its modules.

1 Like