Search code examples
c++cmakeeigenclioneigen3

CLion is unable to find Eigen3 on macOS


I know there have been similar questions in the past. However, none of the solutions have worked for me so far. Just a few details: I am using CLion 2020.1 and Eigen 3.3.7 on macOS 13.13.6. Just an overview of what I have done so far:

  1. I downloaded Eigen 3.3.7 and unzipped the file. After that I renamed the file from "eigen-3.3.7" to "Eigen3".
  2. I moved this to the "usr/local/" directory.
  3. Within "Eigen3", in the "cmake" folder, there is a file called "Eigen3Config.cmake.in". I wondered why it had that extra ".in" extension.
  4. I opened CLion. And this is what I edited the CMakeLists.txt file to look like.

    cmake_minimum_required(VERSION 3.16)
    project(Project_1)
    
    set(CMAKE_CXX_STANDARD 17)
    
    find_package(Eigen3 3.3 REQUIRED NO_MODULE)
    
    add_executable(Project_1 main.cpp)
    target_link_libraries(Project_1 Eigen3::Eigen)
    

This is the error I got:

CMake Error at CMakeLists.txt:6 (find_package):
Could not find a package configuration file provided by "Eigen3" (requested
version 3.3) with any of the following names:

Eigen3Config.cmake
eigen3-config.cmake

Add the installation prefix of "Eigen3" to CMAKE_PREFIX_PATH or set
"Eigen3_DIR" to a directory containing one of the above files.  If "Eigen3"
provides a separate development package or SDK, be sure it has been
installed.

After this, I proceeded to change the file name from "Eigen3Config.cmake.in" to "Eigen3Config.cmake". This is the error I got:

CMake Error at CMakeLists.txt:6 (find_package):
Could not find a configuration file for package "Eigen3" that is compatible
with requested version "3.3".

The following configuration files were considered but not accepted:

/usr/local/Eigen3/cmake/Eigen3Config.cmake, version: unknown

What can I try next?


Solution

  • I thing next solution should help here.

    I downloaded Eigen 3.3.7 and unzipped the file. After that I renamed the file from "eigen-3.3.7" to "Eigen3". I moved this to the "usr/local/" directory.

    Please try to install eige n3.3.7 via brew. Just do brew install eigen. That's it. find_package will find it properly.