Skip to content

Commit d36276b

Browse files
committed
COMP: Expose itkeigen subdir in ITKEigen3_INCLUDE_DIRS for external consumers
ITK ships its vendored Eigen3 headers at Modules/ThirdParty/Eigen3/src/itkeigen/Eigen/<header> ITK code accesses these via the ITK_EIGEN(<header>) macro defined in itk_eigen.h, which expands to <itkeigen/Eigen/<header>> When ITK_USE_SYSTEM_EIGEN=OFF, the prior ITKEigen3_INCLUDE_DIRS contained only ${ITKEigen3_SOURCE_DIR}/src — sufficient for the macro form (the compiler then appends /itkeigen/Eigen/<header>) but not for the upstream Eigen convention <Eigen/<header>>, which needs ${ITKEigen3_SOURCE_DIR}/src/itkeigen on the include path. External consumers that legitimately use the upstream pattern hit 'fatal error: Eigen/Dense: No such file or directory' as soon as they link against ITK::ITKEigen3Module or ITK::eigen_internal. This blocks the modern-target-interfaces refactor in InsightSoftwareConsortium/ITKTotalVariation#57: proxTV's lapackFunctionsWrap.cpp uses #include <Eigen/Dense> and so cannot build against the vendored Eigen via either of ITK's exported imported targets. Add the itkeigen subdirectory to ITKEigen3_INCLUDE_DIRS so both include conventions resolve. ITK's own consumers continue to find <itkeigen/Eigen/<header>> via the first entry; external consumers now find <Eigen/<header>> via the second. Both entries flow into INTERFACE_INCLUDE_DIRECTORIES of the IMPORTED ITK::ITKEigen3Module target, so the fix applies in-tree and to find_package(ITK) consumers alike. The Eigen3::Eigen IMPORTED target produced by Eigen's own export already exposes the correct path, but it is in-source-scope only (declared as add_library(Eigen3::Eigen ALIAS eigen)) and therefore invisible to FetchContent sub-builds; relying on it is not an option for downstream remote modules that pull proxTV via FetchContent. This change is independent of the Eigen 5 vendored update in PR #6176; the architectural mismatch predates that PR and applies to upstream/main as-is.
1 parent 450baaa commit d36276b

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

Modules/ThirdParty/Eigen3/CMakeLists.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,18 @@ if(ITK_USE_SYSTEM_EIGEN)
5555
)
5656
else()
5757
set(ITKEigen3_LIBRARIES eigen_internal)
58-
set(ITKEigen3_INCLUDE_DIRS ${ITKEigen3_SOURCE_DIR}/src)
58+
# Two include directories are required so both ITK's own
59+
# ITK_EIGEN(X) macro convention <itkeigen/Eigen/X> and the upstream
60+
# Eigen convention <Eigen/X> resolve. ITK code rooted at
61+
# ${ITKEigen3_SOURCE_DIR}/src uses the macro form; external
62+
# consumers (proxTV, anything else that includes Eigen the
63+
# standard way) need the parent of <Eigen/X>, which is
64+
# ${ITKEigen3_SOURCE_DIR}/src/itkeigen.
65+
set(
66+
ITKEigen3_INCLUDE_DIRS
67+
${ITKEigen3_SOURCE_DIR}/src
68+
${ITKEigen3_SOURCE_DIR}/src/itkeigen
69+
)
5970
endif()
6071

6172
# For the generated itk_eigen.h

0 commit comments

Comments
 (0)