From d36276b8a9df4311c4b818ba6793acd7f0631bfb Mon Sep 17 00:00:00 2001 From: Hans Johnson Date: Wed, 6 May 2026 13:44:27 -0500 Subject: [PATCH] COMP: Expose itkeigen subdir in ITKEigen3_INCLUDE_DIRS for external consumers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ITK ships its vendored Eigen3 headers at Modules/ThirdParty/Eigen3/src/itkeigen/Eigen/
ITK code accesses these via the ITK_EIGEN(
) macro defined in itk_eigen.h, which expands to > 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/
) but not for the upstream Eigen convention >, 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 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 > via the first entry; external consumers now find > 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. --- Modules/ThirdParty/Eigen3/CMakeLists.txt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Modules/ThirdParty/Eigen3/CMakeLists.txt b/Modules/ThirdParty/Eigen3/CMakeLists.txt index 794c615be55..acd29f41a42 100644 --- a/Modules/ThirdParty/Eigen3/CMakeLists.txt +++ b/Modules/ThirdParty/Eigen3/CMakeLists.txt @@ -55,7 +55,18 @@ if(ITK_USE_SYSTEM_EIGEN) ) else() set(ITKEigen3_LIBRARIES eigen_internal) - set(ITKEigen3_INCLUDE_DIRS ${ITKEigen3_SOURCE_DIR}/src) + # Two include directories are required so both ITK's own + # ITK_EIGEN(X) macro convention and the upstream + # Eigen convention resolve. ITK code rooted at + # ${ITKEigen3_SOURCE_DIR}/src uses the macro form; external + # consumers (proxTV, anything else that includes Eigen the + # standard way) need the parent of , which is + # ${ITKEigen3_SOURCE_DIR}/src/itkeigen. + set( + ITKEigen3_INCLUDE_DIRS + ${ITKEigen3_SOURCE_DIR}/src + ${ITKEigen3_SOURCE_DIR}/src/itkeigen + ) endif() # For the generated itk_eigen.h