Trimming down ITK build to just used parts

I’m investigating trimming down the ANTs superbuild to include the minimum components of ITK/VTK required for it to function.

I was wondering, can anyone suggest a method to determine which components are used so that I can cut back the build. Thanks!

Both VTK and ITK have a utility called:

WhatModulesVTK.py and WhatModulesITK.py.

Use the versions that are in your vtk or itk checkout.

These scripts generate a list of modules referenced in your code tree.
For VTK you should turn off these cmake variables:

BUILD_EXAMPLES:BOOL=OFF .  
BUILD_TESTING:BOOL=OFF
VTK_BUILD_ALL_MODULES_FOR_TESTS:BOOL=OFF
VTK_Group_Rendering:BOOL=OFF
VTK_Group_StandAlone:BOOL=OFF

For ITK,

BUILD_EXAMPLES:BOOL=OFF
BUILD_TESTING:BOOL=OFF
ITK_BUILD_DEFAULT_MODULES:BOOL=OFF
ITKGroup_Core:BOOL=OFF

I have used these scripts to create options for my Open Atlas Project. Here are the External-VTK.cmake and External-ITK.cmake files.

HTH,

Bill

2 Likes

Thanks @bill.lorensen that’s exactly what I was looking for!

1 Like

What Bill provides is a method to reduce the number of ITK modules used in the entire project. This can also be done on a per target level. Reducing the number of include paths during compilation and libraries used during linking or runtime loading of dynamic libraries.

While CMake has a modern (newer then ITK module) system for managing target properties and interfaces. ITK still has a custom module infrastructure.

SimpleITK has a macro to mimic the CMake target_link_libraries interface options to enable target specific linkage and include paths.

You can file the CMake macro here:

and an example usage here:

Using this method adds the modern CMake interface options to your libraries, so transitive properties are automatically handled by CMake.

1 Like

The VTK Examples Project uses the what module to automatically generate a CMakeLists.txt for each example.

For example, see the generated CMakeLists.txt file for the WordCloudDemo example. This works for both the old and new VTK module API’s.

Bill

1 Like