CMake找不到Eigen3 [英] CMake Can't find Eigen3
问题描述
我已将FindEigen3.cmake复制到我的源目录中。
I have copied FindEigen3.cmake into my source directory.
然后我添加:
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR})
CMakeLists.txt,告诉CMake使用这个.cmake文件。
to my CMakeLists.txt to tell CMake to use this .cmake file.
然后在我的CMakeLists.txt我做:
Then in my CMakeLists.txt I do:
FIND_PACKAGE(Eigen3)
我有环境变量EIGEN3_INCLUDE_DIR设置为/ home / doriad / src / eigen
I have the environent variable EIGEN3_INCLUDE_DIR set to /home/doriad/src/eigen
当我运行CMake时,我得到:
When I run CMake, I get:
-- Could NOT find Eigen3 (missing: EIGEN3_INCLUDE_DIR EIGEN3_VERSION_OK) (Required is at least version "2.91.0")
这是一个来自Mercurial的新克隆,所以版本应至少为3。
This is a fresh clone from Mercurial, so the version should be at least 3.
有任何建议吗?
如果我设置模块路径INCORRECTLY,我会得到一些线索:
If I set the module path INCORRECTLY, I get some clues:
Adjust CMAKE_MODULE_PATH to find FindEigen3.cmake or set Eigen3_DIR to the
directory containing a CMake configuration file for Eigen3. The file will
have one of the following names:
Eigen3Config.cmake
eigen3-config.cmake
但是,我没有找到这些文件在源dir或构建目录的Eigen3。我试图设置Eigen3_DIR = / home / doriad / src / eigen,但是也没有工作。
However, I didn't find either of those files in either the source dir or build dir of Eigen3. I tried to set Eigen3_DIR=/home/doriad/src/eigen, but that didn't work either.
想法?
感谢,
大卫
推荐答案
对我来说,当我安装eigen3包(例如使用-DCMAKE_INSTALL_PREFIX = / home / doriad / install),并且还将使用eigen3的cmake包的CMAKE_INSTALL_PREFIX变量设置为同一目录。
It worked for me, when I installed the eigen3 package (e.g. using -DCMAKE_INSTALL_PREFIX=/home/doriad/install), and also set the CMAKE_INSTALL_PREFIX variable of the cmake package that is using eigen3 to the same directory.
由于findscripts的问题,我实际上开始使用 pkg -config 。为此,您需要在eigen3 cmake中启用pkg-config支持,并在您自己的cmake脚本中使用pkg-config宏。优点是您不再需要设置任何环境变量了。
Because of the problems with findscripts, I've actually started using pkg-config instead. For that you need to enable pkg-config support in the eigen3 cmake, and use the pkg-config macro in your own cmake script. Advantage is that you don't need to set any environment variables anymore.
find_package( PkgConfig )
pkg_check_modules( EIGEN3 REQUIRED eigen3 )
include_directories( ${EIGEN3_INCLUDE_DIRS} )
这篇关于CMake找不到Eigen3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!