Eigen3 Find Module Misbehavior When Eigen3 Missing

Issue #152 resolved
Ben Whitney created an issue

I encountered this issue with MOAB 5.3.0, but the version field in the issue form only goes up to 5.2.0.

The Eigen3 find module incorrectly defines EIGEN3_INCLUDES when Eigen3 is not found. As a result, running find_package(MOAB) in another project results in an error message about a directory EIGEN3_DIR-NOTFOUND not existing.

To reproduce, run the following in the root of the repository.

$ git checkout 5.3.0
HEAD is now at 902f803a0 Merged in release/version-5.3.0 (pull request #548)
$ cat > "FindEigen3.patch" <<"EOF"
55a56,57
> message("DEBUG: before `if` statement: EIGEN3_DIR = ${EIGEN3_DIR}")
> 
71a74,75
>   message("DEBUG: before `else` block `find_path` call: EIGEN3_DIR = ${EIGEN3_DIR}")
> 
79a84,85
>   message("DEBUG: after `else` block `find_path` call: EIGEN3_DIR = ${EIGEN3_DIR}")
> 
89a96,97
> 
>   message("DEBUG: at end of `else` block: EIGEN3_INCLUDES = ${EIGEN3_INCLUDES}")
EOF
$ patch config/FindEigen3.cmake FindEigen3.patch
patching file config/FindEigen3.cmake
$ cmake -S . -B "build" 2>&1 1>/dev/null | grep '^DEBUG: '
DEBUG: before `if` statement: EIGEN3_DIR = 
DEBUG: before `else` block `find_path` call: EIGEN3_DIR = 
DEBUG: after `else` block `find_path` call: EIGEN3_DIR = EIGEN3_DIR-NOTFOUND
DEBUG: at end of `else` block: EIGEN3_INCLUDES = -IEIGEN3_DIR-NOTFOUND
$ cmake --build "build" --parallel 1>/dev/null 2>/dev/null
$ grep 'EIGEN3_DIR-NOTFOUND' "build/MOABConfig.cmake"
set(EIGEN3_DIR "EIGEN3_DIR-NOTFOUND")
set (MOAB_PACKAGE_INCLUDES_LIST "       -IEIGEN3_DIR-NOTFOUND  " )

Then install MOAB and run the following in a new directory.

$ cat > "CMakeLists.txt" <<EOF
cmake_minimum_required(VERSION 3.19)
project(debugging)
find_package(MOAB)
EOF
$ cmake -S . -B "build" | grep 'EIGEN3_DIR-NOTFOUND'
-- Include directory EIGEN3_DIR-NOTFOUND does not exist

Comments (7)

  1. Vijay M

    Thank you for raising this issue. Is this on a Windows platform or is the behavior replicable in all platforms ?

  2. Ben Whitney reporter

    This is on Ubuntu. I haven’t tried it on any other platforms.

    $ lsb_release --all
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description:    Ubuntu 18.04.6 LTS
    Release:    18.04
    Codename:   bionic
    

  3. Vijay M

    Can you retest the configuration on this branch: vijaysm/eigen3-TR-configure-fix  ? Do let me know if that fixes it.

  4. Log in to comment