Skip to content

COMP: Do not include UseITK when building as an external module - #60

Closed
hjmjohnson wants to merge 1 commit into
InsightSoftwareConsortium:mainfrom
hjmjohnson:fix-external-build-io-factories
Closed

hjmjohnson wants to merge 1 commit into
InsightSoftwareConsortium:mainfrom
hjmjohnson:fix-external-build-io-factories

Conversation

@hjmjohnson

Copy link
Copy Markdown
Member

Built externally against an ITK that enables ITKIOGE or ITKIOFDF, LesionSizingToolkitTestDriver and LesionSizingToolkitHeaderTest1 fail to link with undefined itk::FDFImageIOFactoryRegister__Private() and itk::GE4ImageIOFactoryRegister__Private(). The top-level include(${ITK_USE_FILE}) is the cause; dropping it fixes the link, and the module template never includes the use file.

Root cause

find_package(ITK REQUIRED) with no components requests every enabled module, and UseITK.cmake then adds ITK_IMAGEIO_FACTORY_REGISTER_MANAGER as a directory-wide compile definition with a generated header listing all 24 image IO factories of that ITK build. Every test object therefore references all 24 *FactoryRegister__Private symbols, while the driver links only this module's dependencies and ITKTestKernel's private IO set, which do not include ITKIOGE or ITKIOFDF. ITKModuleExternal.cmake already applies ITK_REQUIRED_*_FLAGS; the test driver registers the factories it needs through itkTestDriverIncludeRequiredFactories.h.

Test plan

Configured and built the module externally against ITK main (clang, Release, macOS arm64, ITK_WRAP_PYTHON=ON, TEST_CORNELL_DATA_ROOT set) before and after. Before: both executables fail to link as above. After: build.ninja carries no FACTORY_REGISTER_MANAGER definition, the driver links, and ctest passes 52 of 52, including the image-reading tests.

UseITK registers every IO factory of the ITK build as a directory-wide
compile definition, so each test object references the
*ImageIOFactoryRegister__Private symbols of modules this module never
links, and the test driver fails to link against an ITK that has
ITKIOGE or ITKIOFDF enabled. ITKModuleExternal already applies ITK's
flags, and the module template does not include the use file.
@hjmjohnson
hjmjohnson marked this pull request as ready for review October 7, 2026 18:08
@hjmjohnson

Copy link
Copy Markdown
Member Author

Superceeded

@hjmjohnson hjmjohnson closed this Oct 8, 2026
@hjmjohnson hjmjohnson mentioned this pull request Oct 8, 2026
@hjmjohnson

Copy link
Copy Markdown
Member Author

Superseded by #61, which carries this change as 795c9ef ("COMP: Do not include UseITK when building as an external module", unchanged) together with the other fixes CI needs before the test driver can link and pass on every platform.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant