我正在尝试在Windows 10上使用CMake构建一个项目。但是我几个小时都收到这个错误:
错误:
CMake Error at of_dis/CMakeLists.txt:8 (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.
我下载了Eigen,解压缩它,并添加了一个名为EIGEN3_INCLUDE_DIR
的新环境变量,值为C:\eigen-3.3.7\cmake
。另外,我在项目的CMake文件中添加了一行代码,现在看起来像这样:
CMakeLists.txt:
cmake_minimum_required(VERSION 2.8)
project(IMOT_OpticalFlow_Edges)
find_package(OpenCV REQUIRED)
add_subdirectory(of_dis)
include_directories(./of_dis ${OpenCV_INCLUDE_DIRS})
INCLUDE_DIRECTORIES ( "$ENV{EIGEN3_INCLUDE_DIR}" )
set(CMAKE_CXX_STANDARD 11)
#set(OpenCV_DIR "C:/opencv/opencv3.4.1/opencv-3.4.1/build/install")
set(OpenCV_DIR "C:/opencv/opencv3.4.1/opencv-3.4.1/build/install/x64/vc14/lib")
set(SOURCE_FILES src/main.cpp src/support/Place.cpp src/support/Line.cpp src/support/Argument.cpp
src/support/FileOperations.cpp src/frame_processing/FrameProcessor.cpp src/flow_processing/FlowProcessor.cpp
src/edge_processing/EdgeProcessor.cpp src/detection/Detector.cpp)
add_executable(IMOT_OpticalFlow_Edges ${SOURCE_FILES})
target_link_libraries(IMOT_OpticalFlow_Edges ${OpenCV_LIBS})
CMake GUI:
我还复制了当前项目中的FindEigen3.cmake
文件。但我还是一遍又一遍地犯同样的错误。有办法解决吗?
2条答案
按热度按时间nmpmafwu1#
CMake的
find_package()
命令有两种操作模式:Module和Config模式。这个错误本质上是说Modulemode失败,然后Configmode找不到Eigen3包:一般来说,当安装软件包XXX(例如Eigen3)时,该软件包应该配置
XXXConfig.cmake
文件。这样,外部项目就可以通过在Config模式下调用find_package()
来查找和使用XXX包。因为您的Eigen3软件包 * 未安装 *,所以
Eigen3Config.cmake
文件没有配置。因此,Module模式搜索应该对您有用,因为Eigen3目录中只存在FindEigen3.cmake
文件。对于Module模式,必须将FindEigen3.cmake
文件的路径添加到CMAKE_MODULE_PATH
,如错误所示。在find_package(Eigen3 ...)
调用之前添加这一行允许CMakeModule模式成功:8yparm6h2#
我今天遇到了同样的问题,我的解决办法是
1.安装eigen。
1.将Eigen3_config.cmake设置为路径/to/,其中/Eigen3Config.cmake/是
在Windows上,可能是:
C:\Program Files (x86)\Eigen3\share\eigen3\cmake
使用eigen 3的cmake项目参考:
https://eigen.tuxfamily.org/dox/TopicCMakeGuide.html