I am kind of desperate:
For my studies I need to work with Eigen and CMake. I'm able to use Eigen if I copy the whole library in the directories where my compiler looks by default but as soon as I try to find it via
find_package(Eigen3 REQUIRED)
I get the following error:
CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
Could NOT find Eigen3 (missing: EIGEN3_INCLUDE_DIR EIGEN3_VERSION_OK)
(Required is at least version "2.91.0")
Call Stack (most recent call first):
/usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
FindEigen3.cmake:76 (find_package_handle_standard_args)
CMakeLists.txt:8 (find_package)
-- Configuring incomplete, errors occurred!
Now I searched for solutions but all I those I tried (also those available on stackoverflow:
Find package Eigen3 for CMake
or
CMake Can't find Eigen3 )
did not work.
My Eigen Version (according to the Macros in Core/util/Macros.h
) is 3.2.5.
I keep the Eigen directory in /usr/local/include
, I use the FindEigen3.cmake
which comes with the Eigen library and my CMakeLists.txt
looks as follows:
cmake_minimum_required(VERSION 2.8)
project(Test)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
find_package(Eigen3 REQUIRED)
include_directories(${EIGEN3_INCLUDE_DIR})
message("Found Eigen3 in: ${EIGEN3_INCLUDE_DIR}")
add_executable(main test.cpp)
Has anyone an idea what's going wrong?
Kind regards, Julien
find_path()
command to detect the package's include directory. If it's not found automatically you can extendCMAKE_INCLUDE_PATH
by the path where CMake should search (for example see here). So you could add something likelist(APPEND CMAKE_INCLUDE_PATH "/usr/local/include")
before yourfind_package()
command.CMAKE_INCLUDE_PATH
it finds the package - but isn't searching manually exactly what I want to avoid? Shouldn't thefind_package()
do that for me?CMAKE_INCLUDE_PATH
was meant for a non-standardEigen
installation path. I have given your code sample a try and - if I installEigen
into the default path - it seems to work without the need to give the path (see my answer). If you have already used theEigen
installation process, could you please add more details on your environment (CMake version, CMake command line call, host OS, compiler version, ...)?