Skip to content

COMP: Link ITKRegistrationCommonModule for elastix pyramid headers - #2569

Merged
blowekamp merged 1 commit into
SimpleITK:mainfrom
blowekamp:fix-elastix-itk-registration-common-include
Apr 23, 2026
Merged

blowekamp merged 1 commit into
SimpleITK:mainfrom
blowekamp:fix-elastix-itk-registration-common-include

Conversation

@blowekamp

Copy link
Copy Markdown
Member

Problem

When building SimpleITK with Elastix in Superbuild mode on Windows (using ITK_USE_BUILD_DIR=ON), the build fails with:

elxFixedImagePyramidBase.h(26,10): fatal error C1083: Cannot open include file:
'itkMultiResolutionPyramidImageFilter.h': No such file or directory

See the failing dashboard build: https://open.cdash.org/builds/11201211/build

Root Cause

The issue originates from a recent change in the origin/main branch of the elastix repository (commit af47e22 — "ENH: Use target based includes in CMakeLists"). That commit replaced global include_directories(${elxINCLUDE_DIRECTORIES}) with proper target-based target_include_directories(). This is a good change, but it exposed a missing dependency.

The header chain is:

sitkElastixImageFilterImpl.h
  → itkElastixRegistrationMethod.h
    → elxElastixTemplate.h
      → elxFixedImagePyramidBase.h  (public header of elxCore)
        → itkMultiResolutionPyramidImageFilter.h  ← from ITKRegistrationCommon

itkMultiResolutionPyramidImageFilter.h lives in the ITKRegistrationCommon ITK module (Modules/Registration/Common/include/). This is a header-only module — its target ITK::ITKRegistrationCommonModule is an INTERFACE library, and it is not included in the ${ITK_LIBRARIES} variable that elastix uses.

With installed ITK: all headers are merged into a single install include directory, so any ITK-linked target can find all ITK headers regardless of which module they belong to. The build works.

With ITK_USE_BUILD_DIR=ON (build tree ITK): each ITK module has its own separate include directory. Without an explicit dependency on ITK::ITKRegistrationCommonModule, its include path is never added to the compile command, and the header cannot be found. This is the configuration used in the Windows Superbuild CI.

Fix

Add ITK::ITKRegistrationCommonModule as a PRIVATE link dependency of SimpleElastix. This propagates the include directory for itkMultiResolutionPyramidImageFilter.h when building against an ITK build tree.

Note to the Elastix Team

The underlying deficiency is in elastix itself: elxCore's public headers (elxFixedImagePyramidBase.h, elxMovingImagePyramidBase.h) #include "itkMultiResolutionPyramidImageFilter.h", but elxCore's target_link_libraries() does not declare a PUBLIC dependency on ITK::ITKRegistrationCommonModule. As a result, consumers of elxCore (and transitively elastix_lib) do not automatically get the ITKRegistrationCommon include path when using a non-installed ITK.

The proper fix in elastix would be to add to Core/CMakeLists.txt:

target_link_libraries(elxCore PUBLIC
  ITKRegistrationCommon  # or ITK::ITKRegistrationCommonModule
)

This SimpleITK workaround links it directly in SimpleElastix to unblock the Windows CI build in the interim.

@blowekamp

Copy link
Copy Markdown
Member Author

@N-Dekker We ran into this little issue in a certain build configuration with missing ITK interface libraries or include paths when using Elastix as a library.

We could add an explicit "if ITK v6" block add the library dependency in Elastix. What do you think?

@blowekamp

Copy link
Copy Markdown
Member Author

A proper fix should still be done in Elastix, but this should work to clean up the BatchBuild CI for now.

@blowekamp
blowekamp merged commit 4f98389 into SimpleITK:main Apr 23, 2026
10 checks passed
@blowekamp
blowekamp deleted the fix-elastix-itk-registration-common-include branch September 9, 2026 12:55
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.

2 participants