简体   繁体   English

Cmake find_package 未检测到 Windows 中的路径

[英]Cmake find_package does not detect path in windows

I am trying to build the ceres sovler using Cmake_gui and Visual Studio我正在尝试使用 Cmake_gui 和 Visual Studio 构建 ceres sovler

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我将 ceres-solver 克隆到E:\\Code\\libs\\ceres-solver并将所需的库 Eigen3 克隆到E:\\Code\\libs\\eigen-3.3.9

When I run cmake-gui on ceres-solver, I get the following error:当我在 ceres-solver 上运行 cmake-gui 时,出现以下错误:

-- 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:我修改了 ceres CMakeLists.txt 第 241 行:

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?指定 find_package 路径的正确方法是什么? Do I need to use path environment variable within windows or modify CMakeLists.txt?我需要在 Windows 中使用路径环境变量还是修改 CMakeLists.txt?

  2. Am I specifying this path correctly in Windows?我是否在 Windows 中正确指定了此路径? Do I need to link to some internal directory of Eigen3?我需要链接到 Eigen3 的某个内部目录吗? Like E:\\Code\\libs\\eigen-3.3.9\\cmake , use forward slashes instead of back slashes, or use quotation marks for the path?E:\\Code\\libs\\eigen-3.3.9\\cmake ,使用正斜杠而不是反斜杠,还是使用引号作为路径? I tried all of these things without success.我尝试了所有这些事情都没有成功。

  3. Does find_package recursively search for the package within the directories specified? find_package 是否递归搜索指定目录中的包? Or do I need to point to the exact directory?还是我需要指向确切的目录?

Thanks谢谢

According to comments:根据评论:

I must run Cmake-Gui on Eigen3 first, to generate a Build directory.我必须首先在 Eigen3 上运行 Cmake-Gui,以生成一个 Build 目录。 However, it does not necessarily need to be built in VS afterwards,然而,它并不一定要建在VS之后,

Then setting on line 240 in CMakeLists.txt for ceres-solver然后在 CMakeLists.txt 的第 240 行设置 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足以让 Cmake-Gui 找到 Eigen3Config.cmake 文件

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 Eigen3 似乎没有任何必需的依赖项,但是在使用 Cmake-Gui 生成时确实抛出了很多警告,我忽略了这些
  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.不需要 glog 库或任何其他库,但我确实必须检查“启用 mini-glog”选项并重新运行 ceres-solver 的配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM