This forum has been archived. All content is frozen. Please use KDE Discuss instead.

How to use Eigen through CMake?

Tags: None
(comma "," separated)
daviddoria
Registered Member
Posts
46
Karma
0
OS

How to use Eigen through CMake?

Mon Mar 14, 2011 10:49 pm
I tried to use cmake to link my program to Eigen by using:

FIND_PACKAGE(Eigen REQUIRED);
INCLUDE(${Eigen_USE_FILE})

but when I specified by ~/bin/Eigen for Eigen_DIR, it says it can't find EigenConfig.cmake. Am I doing something wrong?

Thanks,

David
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: How to use Eigen through CMake?

Tue Mar 15, 2011 10:32 am
You have to copy the path_to_eigen/cmake/FindEigen3.cmake file in your project tree, e.g., in your_project_path/cmake and ship it with the source.

Then in your CMakeLists.txt file, do something like:
Code: Select all
project(MyProjectUsingEigen)

cmake_minimum_required(VERSION 2.6.2)

set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

find_package(Eigen3 REQUIRED)

include_directories(EIGEN3_INCLUDE_DIR)

set(SRCS main.cpp)
add_executable(myproject ${SRCS})



As an alternative, you can also run cmake this way:

cmake .. -DCMAKE_MODULE_PATH=/path/to/a/directory/containing_the_FindEigen3.cmake_file/

until the FindEigen3.cmake module is shipped with cmake itself.
User avatar
kreykrey
Registered Member
Posts
6
Karma
0

Re: How to use Eigen through CMake?

Wed Aug 31, 2016 12:57 pm
Should read

Code: Select all
include_directories(${EIGEN3_INCLUDE_DIR})


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]