When building SimpleITK's super build against ITK master, I am getting configuration errors when configuring SimpleITK against the install ITK.
I'm configuring SimpleITK with: cmake -DITK_GIT_TAG:STRING=master ~/src/SimpleITK/SuperBuild/
It builds ITK fine, and installs it but then during the SimpleITK configuration the following happens:
CMake Error at /scratch/blowekamp/SimpleITK-ITK/ITK-prefix/lib/cmake/ITK/Modules/ITKEigen3.cmake:15 (find_package):
Could not find a package configuration file provided by "ITKInternalEigen3"
(requested version 3.3) with any of the following names:
ITKInternalEigen3Config.cmake
itkinternaleigen3-config.cmake
Add the installation prefix of "ITKInternalEigen3" to CMAKE_PREFIX_PATH or
set "ITKInternalEigen3_DIR" to a directory containing one of the above
files. If "ITKInternalEigen3" provides a separate development package or
SDK, be sure it has been installed.
Call Stack (most recent call first):
/scratch/blowekamp/SimpleITK-ITK/ITK-prefix/lib/cmake/ITK/ITKModuleAPI.cmake:76 (include)
/scratch/blowekamp/SimpleITK-ITK/ITK-prefix/lib/cmake/ITK/ITKModuleAPI.cmake:31 (itk_module_load)
/scratch/blowekamp/SimpleITK-ITK/ITK-prefix/lib/cmake/ITK/ITKModuleAPI.cmake:129 (_itk_module_config_recurse)
/scratch/blowekamp/SimpleITK-ITK/ITK-prefix/lib/cmake/ITK/ITKConfig.cmake:82 (itk_module_config)
CMakeLists.txt:62 (find_package)
I'm suspicious of #580.
Sorry for that Brad, on it...
Cannot reproduce.
Testing build tree:
cmake ../src/SuperBuild \
-DSimpleITK_USE_SYSTEM_ITK:BOOL=ON -DITK_DIR:PATH=~/Software/ITK/build-ITK-master-buildRelWithDebInfo \
-DWRAP_CSHARP:BOOL=OFF -DWRAP_PYTHON:BOOL=OFF -DWRAP_LUA:BOOL=OFF -DWRAP_TCL:BOOL=OFF \
-DBUILD_TESTING:BOOL=OFF \
-DCMAKE_BUILD_TYPE:STRING=Debug
Configure and build OK.
Testing install tree:
cmake ../src/SuperBuild \
-DSimpleITK_USE_SYSTEM_ITK:BOOL=ON -DITK_DIR:PATH=/tmp/ITK_INSTALL/lib/cmake/ITK-5.0 \
-DWRAP_CSHARP:BOOL=OFF -DWRAP_PYTHON:BOOL=OFF -DWRAP_LUA:BOOL=OFF -DWRAP_TCL:BOOL=OFF \
-DBUILD_TESTING:BOOL=OFF \
-DCMAKE_BUILD_TYPE:STRING=Debug
Configure and build OK.
Could you post the results of:
find /scratch/blowekamp/SimpleITK-ITK/ITK-prefix | grep Eigen3
Mine looks:
find /tmp/ITK_INSTALL | grep Eigen3
/tmp/ITK_INSTALL/lib/cmake/ITK-5.0/Modules/Eigen3ConfigVersion.cmake
/tmp/ITK_INSTALL/lib/cmake/ITK-5.0/Modules/Eigen3Config.cmake
/tmp/ITK_INSTALL/lib/cmake/ITK-5.0/Modules/Eigen3Targets.cmake
/tmp/ITK_INSTALL/lib/cmake/ITK-5.0/Modules/ITKInternalEigen3ConfigVersion.cmake
/tmp/ITK_INSTALL/lib/cmake/ITK-5.0/Modules/ITKInternalEigen3Config.cmake
/tmp/ITK_INSTALL/lib/cmake/ITK-5.0/Modules/ITKInternalEigen3Targets.cmake
/tmp/ITK_INSTALL/lib/cmake/ITK-5.0/Modules/ITKEigen3.cmake
Here is the output of the requested command:
]$ find /scratch/blowekamp/SimpleITK-ITK/ITK-prefix | grep Eigen3
/scratch/blowekamp/SimpleITK-ITK/ITK-prefix/lib/cmake/ITK-5.0/Modules/Eigen3Config.cmake
/scratch/blowekamp/SimpleITK-ITK/ITK-prefix/lib/cmake/ITK-5.0/Modules/Eigen3ConfigVersion.cmake
/scratch/blowekamp/SimpleITK-ITK/ITK-prefix/lib/cmake/ITK-5.0/Modules/ITKInternalEigen3Config.cmake
/scratch/blowekamp/SimpleITK-ITK/ITK-prefix/lib/cmake/ITK-5.0/Modules/ITKInternalEigen3Targets.cmake
/scratch/blowekamp/SimpleITK-ITK/ITK-prefix/lib/cmake/ITK-5.0/Modules/ITKInternalEigen3ConfigVersion.cmake
/scratch/blowekamp/SimpleITK-ITK/ITK-prefix/lib/cmake/ITK-5.0/Modules/Eigen3Targets.cmake
/scratch/blowekamp/SimpleITK-ITK/ITK-prefix/lib/cmake/ITK/Modules/ITKEigen3.cmake
Please see this line in SimpleITK's external ITK project which defines ITK_INSTALL_PACKAGE_DIR=lib/cmake/ITK. You can see above ITK egan is not respecting this configuration variable. This flag is used so that the ITK_DIR path used to configure the SimpleITK sub-project does not need to include the ITK version.
I see, I think the offending line was changed in this commit https://github.com/InsightSoftwareConsortium/ITK/pull/562 and the Eigen3 patch from there is here: https://github.com/InsightSoftwareConsortium/ITK/pull/567.
The change was:
- set(Eigen3_DIR_INSTALL "${CMAKE_INSTALL_PREFIX}/${ITK_INSTALL_LIBRARY_DIR}/cmake/ITK-${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR}/Modules")
+ set(Eigen3_DIR_INSTALL "\${ITK_MODULES_DIR}")
That Eigen3_DIR_INSTALL is used in the find_package(Eigen3) in ITKEigen3.cmake:
set(ITKEigen3_LOADED 1)
set(ITKEigen3_ENABLE_SHARED "0")
set(ITKEigen3_DEPENDS "")
set(ITKEigen3_PUBLIC_DEPENDS "")
set(ITKEigen3_TRANSITIVE_DEPENDS "")
set(ITKEigen3_PRIVATE_DEPENDS "")
set(ITKEigen3_LIBRARIES "ITKInternalEigen3::Eigen")
set(ITKEigen3_INCLUDE_DIRS "${ITK_INSTALL_PREFIX}/include/ITK-5.0")
set(ITKEigen3_LIBRARY_DIRS "")
set(ITKEigen3_RUNTIME_LIBRARY_DIRS "${ITK_INSTALL_PREFIX}/lib")
set(ITKEigen3_TARGETS_FILE "")
set(ITKEigen3_FACTORY_NAMES "")
set(ITKInternalEigen3_DIR "${ITK_MODULES_DIR}")
find_package(ITKInternalEigen3 3.3 REQUIRED CONFIG)
The changes to Eigen3 are required as ITK is built using R CMD check, which creates a temporary folder to check the package and build the binary: https://travis-ci.org/muschellij2/ITKR/jobs/500018126#L2538. The change ensures that ITKEigen3.cmake in the output has a relative path as currently it is using ${CMAKE_INSTALL_PREFIX}, which makes it less robust, especially if the path is moved. This causes issues when a package wishes to build on ITK, such as ANTs, which is built in R using ANTsRCore and the binary ITKR which was built above: https://travis-ci.org/muschellij2/ANTsRCore/jobs/500018491#L6596. The error here relates to the absolute path Eigen3 is making in the cmake file.
You can see above ITK Eigen is not respecting this configuration variable
I see, so the problem is that the cmake files shouldn't be installed in the /ITK-5.0/Modules but in ITK_INSTALL_PACKAGE_DIR/Modules. So the problem might lie in the install path I am using inside Eigen.
I'll fix it.
Found the offender:
I guess that should be equal to ITK_INSTALL_PACKAGE_DIR/Modules
Great!