I am trying to get Eigen up and running but I am running into a roadblock. I opened Clion and in the CMakeLists.txt tab I entered the following code. Please note I have installed Eigen with home-brew.
project(untitled)
cmake_minimum_required(VERSION 3.7)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
find_package(Eigen3 REQUIRED)
include_directories(EIGEN3_INCLUDE_DIR)
set(SRCS main.cpp)
add_executable(untitled ${SRCS})
I am getting the following error.
/Applications/CLion.app/Contents/bin/cmake/bin/cmake -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" /Users/johnmcconnell/CLionProjects/untitled
CMake Error at CMakeLists.txt:9 (find_package):
Found package configuration file:
/usr/local/share/eigen3/cmake/Eigen3Config.cmake
but it set Eigen3_FOUND to FALSE so package "Eigen3" is considered to be
NOT FOUND.
I've never done this before and I am really at a loss, any ideas on what to do?
UPDATE: Change in code clears the error but yields a new one.
fatal error: 'Eigen/Dense' file not found
project(untitled)
cmake_minimum_required(VERSION 3.7)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include_directories(EIGEN_INCLUDE_DIR)
set(SRCS main.cpp)
add_executable(untitled ${SRCS})
If you look at the source code of the CMake module: https://github.com/RLovelett/eigen/blob/master/cmake/FindEigen3.cmake
You can see that it accepts "hints" in either
EIGEN3_ROOT
orEIGEN3_ROOT_DIR
. Set one of those to the base of your Eigen installation and try again:Include the following in CMakeLists.txt
The directory in which you placed Eigen's source code must be in the include path
EIGEN_DIR
is set to the path where the Eigen folder is in your system#include <Eigen>
in the files where ever you are using Eigen... Hope this answer helps you :DIn addition to the problem solved by @John Zwinck's answer, you have an error in your
include_directories
statement.It should be
instead of