更新时间:2022-01-10 06:43:14
由于 Eigen3 完全只是标题,因此您只需要包含目录的路径.而这个,无论如何你已经在手动定义了.所以实际上不需要 FindEigen3.cmake
或 FIND_PACKAGE
调用.
Since Eigen3 is completely header only, all you ever need is the path to the include directory. And this one, you are already defining manually anyway. So there is no real need for a FindEigen3.cmake
or FIND_PACKAGE
call.
简单使用
INCLUDE_DIRECTORIES ( "$ENV{EIGEN3_INCLUDE_DIR}" )
或
SET( EIGEN3_INCLUDE_DIR "$ENV{EIGEN3_INCLUDE_DIR}" )
IF( NOT EIGEN3_INCLUDE_DIR )
MESSAGE( FATAL_ERROR "Please point the environment variable EIGEN3_INCLUDE_DIR to the include directory of your Eigen3 installation.")
ENDIF()
INCLUDE_DIRECTORIES ( "${EIGEN3_INCLUDE_DIR}" )
一些注意事项:
${...}
$ENV{....}
访问环境变量.CMAKE_MODULE_PATH
指向它所在的目录.不确定,但可能是 CMake 也会自动检查当前目录(您的 CMakeLists.txt
所在的位置.无论如何,设置 EIGEN3_INCLUDE_DIR
与 EIGEN3_INCLUDE_DIR
的位置完全无关代码>FindEigen3.cmakeFindEigen3
脚本可能会评估这个变量以确定您的 Eigen3 安装位置.Config.cmake
.如果您将名为 _DIR
的变量指向包含此文件的目录,您可以正常使用 FIND_PACKAGE( <PackageName> ...)
.有关详细信息,请参阅FIND_PACKAGE 的文档.${...}
$ENV{....}
accesses environment variables.CMAKE_MODULE_PATH
to the directory where it is. Not sure, but it could be that CMake checks the current directory as well automatically (where your CMakeLists.txt
resides. Anyhow, setting EIGEN3_INCLUDE_DIR
is totally unrelated to the location of FindEigen3.cmake
FindEigen3
script evaluates this variable to determine the location of your Eigen3 installation.<PackageName>Config.cmake
. If you point a variable called <PackageName>_DIR
to the directory containing this file, you can use FIND_PACKAGE( <PackageName> ...)
as normal. See documentation of FIND_PACKAGE for details.