1

I am trying to build the ceres sovler using Cmake_gui and Visual Studio

I have ceres-solver cloned to E:\Code\libs\ceres-solver and the required library Eigen3 cloned to E:\Code\libs\eigen-3.3.9

When I run cmake-gui on ceres-solver, I get the following error:

-- Detected available Ceres threading models: [CXX_THREADS, OPENMP, NO_THREADS]
-- Building with C++14
CMake Error at CMakeLists.txt:242 (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" (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.

I modified ceres CMakeLists.txt line 241 from:

find_package(Eigen3 3.3 REQUIRED)

to

find_package(Eigen3 3.3 REQUIRED PATH "E:/Code/libs/eigen-3.3.9")

But I still get this error above

I also tried

list(APPEND CMAKE_PREFIX_PATH "E:/Code/libs/eigen-3.3.9")

set(Eigen3_DIR "E:/Code/libs/eigen-3.3.9")

My questions are:

  1. What is the correct way to specify the path for find_package? Do I need to use path environment variable within windows or modify CMakeLists.txt?

  2. Am I specifying this path correctly in Windows? Do I need to link to some internal directory of Eigen3? Like E:\Code\libs\eigen-3.3.9\cmake, use forward slashes instead of back slashes, or use quotation marks for the path? I tried all of these things without success.

  3. Does find_package recursively search for the package within the directories specified? Or do I need to point to the exact directory?

Thanks

Mich
  • 3,188
  • 4
  • 37
  • 85
  • Just to make sure, but the directory specified contains the built libraries, and not just the cloned source of `Eigen3` – Lala5th Jul 26 '21 at 20:51
  • just the source code, I though CMake would build everything into 1 project – Mich Jul 26 '21 at 20:52
  • 1
    `find_package` searches for built cmake packages and not for the sources. I think there is a way to build it together with the main project, but I'm not sure how exactly to configure that. – Lala5th Jul 26 '21 at 20:54
  • You need to use CMake to generate a project and build Eigen3 separately for you. You can also use vcpkg to help do this for you: [https://github.com/microsoft/vcpkg](https://github.com/microsoft/vcpkg) – drescherjm Jul 26 '21 at 21:04

1 Answers1

1

According to comments:

I must run Cmake-Gui on Eigen3 first, to generate a Build directory. However, it does not necessarily need to be built in VS afterwards,

Then setting on line 240 in CMakeLists.txt for ceres-solver

list(APPEND CMAKE_PREFIX_PATH "E:/Code/libs/eigen-3.3.9/build")

Was sufficient for Cmake-Gui to find the Eigen3Config.cmake file

Notes:

  1. Eigen3 does not have any required dependencies it seems, but it does throw a lot of warnings when generating with Cmake-Gui, I ignored these
  2. glog library or any other libraries are not required, but I did have to check "Enable mini-glog" option and re-run config for ceres-solver.
Mich
  • 3,188
  • 4
  • 37
  • 85