Skip to content

BUG: Restore eigen_internal export to ITK's main targets set (#6239)#6247

Open
hjmjohnson wants to merge 1 commit intoInsightSoftwareConsortium:mainfrom
hjmjohnson:eigen-robustness-2026-05-09
Open

BUG: Restore eigen_internal export to ITK's main targets set (#6239)#6247
hjmjohnson wants to merge 1 commit intoInsightSoftwareConsortium:mainfrom
hjmjohnson:eigen-robustness-2026-05-09

Conversation

@hjmjohnson
Copy link
Copy Markdown
Member

@hjmjohnson hjmjohnson commented May 9, 2026

Restores eigen_internal to ITK's main ${ITK3P_INSTALL_EXPORT_NAME} export set so find_package(ITK) resolves it for downstream consumers (closes #6239 — SimpleITK CI red since 2026-05-01).

Scope note: this addresses only the most immediate regression. The broader Eigen3 design questions (header-path policy #5952 vs #6225, symbol mangling, VNL→Eigen migration, the _SYSTEM_INCLUDE_DIRS asymmetry #6224) remain in the master tracking issue #6230 and are deliberately not touched here.

Root cause (issue #6239)

Commit 64ddc666 (Eigen 5.0.1 vendored update, 2026-05-01) silently moved eigen_internal out of ITK's main ${ITK3P_INSTALL_EXPORT_NAME} export set into a standalone ITKInternalEigen3Targets. Because ITKConfig.cmake only loads ITKTargets.cmake, downstream find_package(ITK) could no longer resolve eigen_internal and any consumer using FetchContent with FIND_PACKAGE_ARGS (SimpleITK's pattern) hit a target-collision cascade as CMake fell back to add_subdirectory.

The fix re-adds the install rule that registers eigen_internal in the main export set while keeping the standalone ITKInternalEigen3Targets install for find_package(ITKInternalEigen3) consumers. Both export sets now reference the same target — same pattern as every other ITK-vendored third party (NrrdIO, NIFTI, Expat, OpenJPEG, DICOMParser).

Local verification — SimpleITK before/after differential

Reproduced against latest SimpleITK upstream (853c78a9, 2026-05-09) using two parallel ITK installs at the same configuration (ITK_BUILD_DEFAULT_MODULES=ON + Module_ITKIOTransformMINC=ON + Module_ITKReview=ON, matching SuperBuild/External_ITK.cmake):

source install prefix
baseline upstream/main 7820bbcfb8 (no fix) ~/src/ITK-eigen-baseline-install
fix-applied this PR's tip ~/src/ITK-build-test-tree-eigen/install-fix

Pre-flight: eigen_internal in installed ITKTargets.cmake

$ grep -c 'add_library(ITK::eigen_internal' install-fix/lib/cmake/ITK-6.0/ITKTargets.cmake
1
$ grep -c 'add_library(ITK::eigen_internal' ITK-eigen-baseline-install/lib/cmake/ITK-6.0/ITKTargets.cmake
0
$ find ITK-eigen-baseline-install -name 'ITKInternalEigen3Targets*.cmake'
ITK-eigen-baseline-install/share/ITKInternalEigen3Targets.cmake     # orphan; not loaded by ITKConfig

SimpleITK configure against each install:

cmake -G Ninja -S ~/src/SimpleITK -B sitk-bld \
  -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF -DWRAP_DEFAULT=OFF \
  -DITK_DIR=<install>/lib/cmake/ITK-6.0
find_package(ITK) FetchContent fallback (_deps/itk-src/) Error cascade
baseline FAILED YES — materialized add_library cannot create target "itksys" because an imported target with the same name already exists (exact #6239 cascade)
this PR -- ITK found via find_package() NO unrelated SimpleITK codegen issues that reproduce on either ITK

The fix resolves the export-set regression cleanly. Verification comment with full reproduction steps posted to this PR.

What remains for #6230

This PR does not address (deferred per #6230 design discussion 2026-05-07/09):

@github-actions github-actions Bot added type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots area:ThirdParty Issues affecting the ThirdParty module labels May 9, 2026
@hjmjohnson
Copy link
Copy Markdown
Member Author

@greptile review

@hjmjohnson
Copy link
Copy Markdown
Member Author

SimpleITK build verification — before/after differential

Reproduced the SimpleITK failure against latest SimpleITK upstream (853c78a9, 2026-05-09) using two parallel ITK installs:

source install prefix
baseline upstream/main 7820bbcfb8 (no fix) ~/src/ITK-eigen-baseline-install
fix-applied this PR's tip 5dfd84ac7b ~/src/ITK-build-test-tree-eigen/install-fix

Both ITK builds: ITK_BUILD_DEFAULT_MODULES=ON + Module_ITKIOTransformMINC=ON + Module_ITKReview=ON (the SimpleITK Superbuild's required set per SuperBuild/External_ITK.cmake).

Pre-flight: eigen_internal in installed ITKTargets.cmake

$ grep -c 'add_library(ITK::eigen_internal' \
    install-fix/lib/cmake/ITK-6.0/ITKTargets.cmake
1
$ grep -c 'add_library(ITK::eigen_internal' \
    ITK-eigen-baseline-install/lib/cmake/ITK-6.0/ITKTargets.cmake
0
$ find ITK-eigen-baseline-install -name 'ITKInternalEigen3Targets*.cmake'
ITK-eigen-baseline-install/share/ITKInternalEigen3Targets.cmake

Baseline confirms eigen_internal is absent from the main ITKTargets.cmake and lives in an orphan ITKInternalEigen3Targets.cmake that ITKConfig.cmake never loads.

SimpleITK configure against each install

cmake -G Ninja -S ~/src/SimpleITK -B sitk-bld \
  -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF -DWRAP_DEFAULT=OFF \
  -DITK_DIR=<install>/lib/cmake/ITK-6.0

Baseline (no fix): find_package(ITK) partially fails → SimpleITK's FetchContent ... FIND_PACKAGE_ARGS fallback materializes _deps/itk-src/ and tries add_subdirectory, producing the exact cascade from #6239:

CMake Error at .../Modules/ThirdParty/KWSys/src/KWSys/CMakeLists.txt:749 (add_library):
  add_library cannot create target "itksys" because an imported target with
  the same name already exists.
CMake Error at .../Modules/ThirdParty/KWSys/src/KWSys/CMakeLists.txt:764 (target_link_libraries):
  Cannot specify link libraries for target "itksys" which is not built by
  this project.

_deps/itk-src/ directory present → FetchContent fallback was triggered.

PR #6247: find_package(ITK) resolves cleanly:

-- ITK found via find_package()

_deps/itk-src/ NOT present → no FetchContent fallback. Configure proceeds past the eigen-related code path. (The configure ultimately stops on unrelated SimpleITK-specific issues — Python SimpleITKBasicFiltersGeneratedHeaders.i codegen — which are independent of the eigen export-set fix and reproduce on either ITK regardless.)

Differential summary

find_package(ITK) FetchContent fallback Error cascade
baseline (no fix) FAILED yes — _deps/itk-src/ present itksys imported-target collision (exact #6239)
PR #6247 -- ITK found via find_package() no unrelated SimpleITK codegen issues

The fix resolves the export-set regression cleanly. Whatever else SimpleITK CI surfaces is independent of this PR.

…SoftwareConsortium#6239)

Commit 64ddc66 (Eigen 5.0.1 vendored update, 2026-05-01) silently
moved eigen_internal out of ITK's main `${ITK3P_INSTALL_EXPORT_NAME}`
export set into a standalone `ITKInternalEigen3Targets`. Because
`ITKConfig.cmake` only loads `ITKTargets.cmake`, downstream
`find_package(ITK)` could no longer resolve `eigen_internal` and any
consumer using FetchContent with `FIND_PACKAGE_ARGS` (SimpleITK's
pattern) hit a target-collision cascade as CMake fell back to
`add_subdirectory`.

Re-add the install rule that registers `eigen_internal` in
`${ITK3P_INSTALL_EXPORT_NAME}` while keeping the existing standalone
`ITKInternalEigen3Targets` install for `find_package(ITKInternalEigen3)`
consumers. Both export sets now reference the same target.

Issue: InsightSoftwareConsortium#6239
@greptile-apps

This comment was marked as resolved.

@hjmjohnson hjmjohnson force-pushed the eigen-robustness-2026-05-09 branch from 5dfd84a to c1715d9 Compare May 9, 2026 16:29
@hjmjohnson hjmjohnson marked this pull request as ready for review May 9, 2026 16:32
@blowekamp
Copy link
Copy Markdown
Member

How was the ITK eigen for updated? ITK commit 7aa8ae2 indicates set of changes in the eigen fork:

# By Eigen Upstream
* upstream-Eigen3:
  Eigen3 2026-03-12 (b581628e)

Were these changes from the prior eigen commit included in the update to the fork?

@hjmjohnson
Copy link
Copy Markdown
Member Author

Downstream-consumer end-to-end verification (BRAINSTools + SimpleITK)

Built two real-world ITK consumers against the install-fix ITK install (this PR's tip, ITK 6.0 with ITK_BUILD_DEFAULT_MODULES=ON + Module_ITKIOTransformMINC=ON + Module_ITKReview=ON). All against latest upstream tips of each consumer.

SimpleITK — full build ✅

  • Source: SimpleITK/main at 853c78a9 (2026-05-09)
  • cmake -DITK_DIR=…/install-fix/lib/cmake/ITK-6.0 -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF -DWRAP_DEFAULT=OFF
  • cmake --build -j6984/984 targets, 0 errors, 4 warnings (warnings are SimpleITK-internal, not Eigen-related)
  • find_package(ITK) resolution: -- ITK found via find_package() clean
  • No _deps/itk-src/ materialized (no FetchContent fallback was triggered)
  • Zero Eigen mentions in the build log
  • All libSimpleITK*.a artifacts produced

BRAINSTools — configure clean, build blocked by unrelated module-config issue ⚠️

  • Source: BRAINSTools/main at 67acae44 (2026-04-12)
  • cmake -DUSE_SYSTEM_ITK=ON -DITK_DIR=…/install-fix/lib/cmake/ITK-6.0 -DBRAINSTools_REQUIRES_VTK=OFF -DBRAINSTools_BUILD_DICOM_SUPPORT=OFF
  • Outer Superbuild configure: ✅ clean
  • Inner ANTs configure: ✅ find_package(ITK 5.4 ...) succeeded (ITK 6.0 satisfies the ≥ 5.4 floor; no version-pin enforcement); ITK_VERSION_MAJOR=6 recorded in ANTs CMakeCache
  • Inner ANTs build: ❌ fatal error: 'itkLabelImageGenericInterpolateImageFunction.h' file not found in antsRegistrationTemplateHeader.h:21unrelated to Eigen; needs Module_GenericLabelInterpolator=ON enabled in the ITK install. This is a pre-existing ANTs+ITK6 module-set integration issue independent of PR BUG: Restore eigen_internal export to ITK's main targets set (#6239) #6247.
  • Eigen path through ANTs configure resolved cleanly; the eigen_internal import target is correctly available.

Bottom line for this PR

The Eigen export-set regression #6239 is fixed for both downstream consumers tested. Where builds proceed past configure, no Eigen-related compile or link errors appear. The one BRAINSTools subbuild that failed died on a missing remote-module header — a separate ITK-build-time configuration concern unrelated to the eigen_internal install rule.

Reproducer state preserved: ~/src/ITK-build-test-tree-eigen/install-fix/, /tmp/sitk-fix-fullbld/, /tmp/brains-bld/.

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

Labels

area:ThirdParty Issues affecting the ThirdParty module type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Eigen3 update (64ddc666) breaks downstream FetchContent+find_package use of ITK — eigen_internal removed from main export set

2 participants