在 Windows 中配置 cmake 项目时未找到 Eigen3_DIR

2023-12-26

我想编译一个开放项目 https://github.com/ppwwyyxx/OpenPano,它需要 Eigen3,我遵循了它的指南,但停留在这一步:

“将环境变量 Eigen3_DIR 设置为 {YOUR_EIGEN3_DIRECTORY}/eigen3/cmake。”

我已经安装了 CMake gui,配置后它打印出以下错误

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 http://eigen.tuxfamily.org/index.php?title=Main_Page, 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.


我假设您使用的是 Windows。您需要安装 Visual Studio。您可以使用社区版本。您需要执行以下操作:

  1. 在 Eigen 目录中创建一个名为“build”的目录。
  2. 转到构建目录并执行“cmake ..”。这将创建 Visual Studio 项目。
  3. 使用 Visual Studio 加载 .sln。
  4. 构建解决方案。
  5. 确保名为 INSTALL 的项目也已构建。

这将在您的安装目录中创建 Eigen3Config.cmake 文件。在我的例子中,安装目录是“C:\Program Files(X86)\Eigen3。使用它作为 Eigen3_DIR 变量的值。 默认情况下,Eigen 不附带 Eigen3Config.cmake 文件。您将看到 Eigen3Config.cmake.in 文件。这用于构建 Eigen3Config.cmake 文件。

HTH

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在 Windows 中配置 cmake 项目时未找到 Eigen3_DIR 的相关文章

随机推荐