問題
在 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