Question

CMake Can't find Eigen3

I have copied FindEigen3.cmake into my source directory.

I then added:

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR})

to my CMakeLists.txt to tell CMake to use this .cmake file.

Then in my CMakeLists.txt I do:

FIND_PACKAGE(Eigen3)

I have the environent variable EIGEN3_INCLUDE_DIR set to /home/doriad/src/eigen

When I run CMake, I get:

-- Could NOT find Eigen3 (missing: EIGEN3_INCLUDE_DIR EIGEN3_VERSION_OK) (Required is at least version "2.91.0")

This is a fresh clone from Mercurial, so the version should be at least 3.

Any suggestions?

If I set the module path INCORRECTLY, I get some clues:

Adjust CMAKE_MODULE_PATH to find FindEigen3.cmake or set Eigen3_DIR to the
directory containing a CMake configuration file for Eigen3. The file will
have one of the following names:

Eigen3Config.cmake
eigen3-config.cmake

However, I didn't find either of those files in either the source dir or build dir of Eigen3. I tried to set Eigen3_DIR=/home/doriad/src/eigen, but that didn't work either.

Thoughts?

Thanks,

David

 21  27449  21
1 Jan 1970

Solution

 8

It worked for me, when I installed the eigen3 package (e.g. using -DCMAKE_INSTALL_PREFIX=/home/doriad/install), and also set the CMAKE_INSTALL_PREFIX variable of the cmake package that is using eigen3 to the same directory.

Because of the problems with findscripts, I've actually started using pkg-config instead. For that you need to enable pkg-config support in the eigen3 cmake, and use the pkg-config macro in your own cmake script. Advantage is that you don't need to set any environment variables anymore.

find_package( PkgConfig )
pkg_check_modules( EIGEN3 REQUIRED eigen3 )
include_directories( ${EIGEN3_INCLUDE_DIRS} )
2011-06-12