Skip to content

Commit 44f1bac

Browse files
committed
DOC: Add factory meta-module guidance for external project test drivers
Document the preferred pattern for external projects (RTK, BRAINSTools, remote modules) to register FFT, IO, and other factory backends in their test drivers: link against ITK::ITKFFTImageFilterInit instead of manually calling RegisterFactory() for each backend. This was identified during review of PR #6073 — Brad Lowekamp noted that target_link_libraries(... PRIVATE ITK::ITKFFTImageFilterInit) is more maintainable than copying explicit factory registration code.
1 parent 8483b54 commit 44f1bac

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

Documentation/docs/migration_guides/itk_6_migration_guide.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,36 @@ target_link_libraries(MyTarget ${ITK_INTERFACE_LIBRARIES} ITK::ITKImageIO)
396396
In this example, the GDCM and NRRD ImageIO modules are explicitly loaded. Only the ImageIO factory type is registered and generated.
397397

398398

399+
**Factory Registration in External Project Test Drivers:**
400+
401+
External projects (like RTK, BRAINSTools, or ITK remote modules) that need FFT, IO, or other
402+
factory-registered backends in their test drivers should **link against the meta-module target**
403+
rather than manually calling `RegisterFactory()`. This ensures the correct backends are
404+
registered automatically and stays in sync with the ITK build configuration.
405+
406+
```cmake
407+
# In your external project's test CMakeLists.txt:
408+
find_package(ITK REQUIRED COMPONENTS ITKFFT)
409+
itk_generate_factory_registration()
410+
411+
add_executable(MyTestDriver myTestDriver.cxx)
412+
target_link_libraries(MyTestDriver
413+
PRIVATE
414+
ITK::ITKFFTImageFilterInit # Registers FFTW (if available) + VNL FFT backends
415+
ITK::ITKImageIO # Registers all image IO formats
416+
ITK::ITKMeshIO # Registers all mesh IO formats
417+
ITK::ITKTransformIO # Registers all transform IO formats
418+
)
419+
```
420+
421+
This replaces the legacy pattern of manually including factory headers and calling
422+
`itk::ObjectFactoryBase::RegisterFactory()` for each backend. The meta-module approach is
423+
preferred because:
424+
425+
- New backends are picked up automatically when ITK is reconfigured
426+
- Factory priority ordering is handled by the module system
427+
- No `#if defined(ITK_USE_FFTWF)` guards needed in application code
428+
399429
**Determining Required Modules:**
400430

401431
To identify which ITK modules your code depends on, use the `WhatModulesITK.py` utility:

0 commit comments

Comments
 (0)