[英]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:我的问题是:
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?
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.我尝试了所有这些事情都没有成功。
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:笔记:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.