CMake 报错OpenCV_FOUND to FALSE so package “OpenCV“ is considered to be NOT FOUND | 九七的CMake常见问题集锦

CMake 报错set OpenCV_FOUND to FALSE so package “OpenCV“ is considered to be NOT FOUND

环境

Windows 10
Visual Studio 2019
Opencv 3.1.0
CMake 3.20.2

复现

打开cmd命令行
进入需编译的项目的./build文件中
使用cmake编译:

cmake ..

BUG

CMake Error at CMakeLists.txt:10 (find_package):
Found package configuration file:

D:/opencv/opencv3.1.0/opencv/build/OpenCVConfig.cmake

but it set OpenCV_FOUND to FALSE so package “OpenCV” is considered to be
NOT FOUND.

原因

查看OpenCVConfig.cmake,3.1.0的OpenCV无法兼容VS2019,cmake文件中没有适合VS2019的MSVC_VERSION ,OpenCV_RUNTIME无法获取到值。

解决

1.降低Visual Studio 版本
2.提高OpenCV的版本

实践

OpenCV3.1.0改用为4.5.2问题解决

来自:九七的CMake常见问题集锦(转载请注明出处)

你可能感兴趣的:(九七的CMake常见问题集锦,opencv,cmake,c++,vs2019,报错)