如何设置 CMake 变量以包含目录

How to set CMake variable to include directory

当尝试从 VS 的开发人员命令提示符中使用 Cmake 构建 this library 时,出现此错误

CMake Error at cmake/FindEigen.cmake:77 (MESSAGE):
  Failed to find Eigen - Could not find eigen3 include directory, set
  EIGEN_INCLUDE_DIR to path to eigen3 include directory, e.g.
  /usr/local/include/eigen3.

我想了解我的意图:我是要使用命令行参数设置 EIGEN_INCLUDE_DIR 还是通过编辑 make 文件?

我试过 cmake -D EIGEN_INGLUDE_DIR=C:\Users\a\Downloads\eigen-3.3.7\eigen-3.3.7 . 但收到同样的错误。

cmake -D EIGEN_INGLUDE_DIR=C:\Users\a\Downloads\eigen-3.3.7\eigen-3.3.7 . 没有创建任何文件就失败了(cmake .. 至少开始构建)并给了我这个错误

CMake Error: The source "C:/Users/a/Downloads/RpolyPlusPlus-master/RpolyPlusPlus-master/build/CMakeLists.txt" does not match the source "C:/Users/a/Downloads/RpolyPlusPlus-master/RpolyPlusPlus-master/CMakeLists.txt" used to generate cache. Re-run cmake with a different source directory.

所以我最终将其添加到 .cmake 文件中:

# TODO: Add standard Windows search locations for Eigen.
LIST(APPEND EIGEN_CHECK_INCLUDE_DIRS
  /usr/local/include
  /usr/local/homebrew/include # Mac OS X
  /opt/local/var/macports/software # Mac OS X.
  /opt/local/include
  /usr/include
  C:\Users\a\Downloads\eigen-3.3.7)  <---------------------------------------