我正试图在Windows10上使用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.
我下载了特征,提取了它,并添加了一个名为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图形用户界面:
我还在当前项目中复制了FindEigen3.cmake
文件。但我仍然一次又一次地犯同样的错误。有办法解决这个问题吗?
发布于 2020-02-07 12:40:05
为了完整地总结这些评论意见:
CMake的find_package()
命令有两种操作模式:模块和Config模式。此错误实质上说模块模式失败,然后Config模式无法找到Eigen3包:
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.
通常,当安装了某某软件包(例如Eigen3 )时,该包应该配置XXXConfig.cmake
文件。这样,外部项目就可以通过在find_package()
Config模式下调用来查找和使用package。
因为您的Eigen3包没有安装,所以没有配置Eigen3Config.cmake
文件。因此,模块模式搜索应该适合您,因为只有FindEigen3.cmake
文件存在于Eigen3目录中。对于模块模式,如错误所示,必须将FindEigen3.cmake
文件的路径添加到CMAKE_MODULE_PATH
中。在find_package(Eigen3 ...)
调用之前添加这一行允许CMake Module模式成功:
list(APPEND CMAKE_MODULE_PATH "C:/eigen-3.3.7/cmake")
https://stackoverflow.com/questions/60103934
复制相似问题