Not found Eigen3_DIR when configuring a cmake project in Windows
Asked Answered
N

1

6

I want to compile an open project, it needs Eigen3, I followed its guideline but stuck in this step:

"Set environment variable Eigen3_DIR to {YOUR_EIGEN3_DIRECTORY}/eigen3/cmake."

I have installed CMake gui and it printed following errors after configuration

Make Error at src/CMakeLists.txt:15 (find_package):
  By not providing "FindEigen3.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Eigen3", but
  CMake did not find one.

  Could not find a package configuration file provided by "Eigen3" 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.

But I have downloaded Eigen3 from here, and set the Eigen3_DIR as follows enter image description here So what should I do to fix it? I am just a beginner in cmake.

Neva answered 8/1, 2018 at 4:55 Comment(3)
Try to add {YOUR_EIGEN3_DIRECTORY} to CMAKE_PREFIX_PATH in CMake GUI as the error message suggests.Windbag
As error message suggests, directory contained in Eigen3_DIR variable should contain file Eigen3Config.cmake. Check that.Cellulosic
have you found a solution?Newspaperman
S
8

I am assuming you are using Windows. You will need Visual Studio installed. You can use the community version. You will need to do the following:

  1. Create a directory called "build" within your Eigen directory.
  2. Go to the build directory and do "cmake ..". This will create Visual Studio projects.
  3. Load the .sln using Visual Studio.
  4. Build the solution.
  5. Ensure that the project called INSTALL was built also.

This will create the Eigen3Config.cmake file in your install directory. In my case the install directory was "C:\Program Files(X86)\Eigen3. Use this to as the value for Eigen3_DIR variable. By default Eigen does not come with the Eigen3Config.cmake file. You will see Eigen3Config.cmake.in file. This is used to build the Eigen3Config.cmake file.

HTH

Sabra answered 2/4, 2019 at 13:49 Comment(1)
It's quite unintuitive that one should have to "build" a header-only library, but this worked, so thank you. As a sidenote, you should be able to specify a custom installation directory with cmake -D CMAKE_INSTALL_PREFIX=your/install/dir ..Bobcat

© 2022 - 2024 — McMap. All rights reserved.