VS2017+CMake+OpenCV下报错 set OpenCV_FOUND to FALSE

问题

在 VS 2017 中使用Cmake 管理项目, 使用 opencv 库, 在find package的时候出现能找到 OpenCVConfig.cmake的文件,但是设置 OpenCV_Found 为 false。

CMake Warning at E:/dependence/opencv/OpenCVConfig.cmake:156 (message):
  Found OpenCV Windows Pack but it has no binaries compatible with your
  configuration.
  You should manually point CMake variable OpenCV_DIR to your build of OpenCV
  library.
Call Stack (most recent call first):
  CMakeLists.txt:15 (find_package)
CMake Error at CMakeLists.txt:15 (find_package):
  Found package configuration file:
    E:/dependence/opencv/OpenCVConfig.cmake
  but it set OpenCV_FOUND to FALSE so package "OpenCV" is considered to be
  NOT FOUND.

解决办法

我的 opencv 链接库路径为 E:\dependence\opencv\x64\vc15; 显然这是 x64平台的库,所以生成器也要设置为 Win64平台下。

在 CMakeSettings.json 中;把 "generator":"Visual Studio 15 2017" 改为
"Visual Studio 15 2017 Win64"

Ref:
https://stackoverflow.com/questions/31931397/error-configuring-opencv-project-with-cmake-on-windows

posted @ 2019-02-12 21:35  行者孙  阅读(5097)  评论(0编辑  收藏  举报