简体   繁体   English

CMake找不到OpenCVConfig.cmake

[英]CMake can't find OpenCVConfig.cmake

I'm trying to make OpenCV work with CMake in Clion on Windows 10 (64bit). 我正在尝试使OpenCV与Windows 10(64位)上的Clion中的CMake一起使用。 I've already set OPENCV_DIR to the OpenCV build folder that contains OpenCVConfig.cmake , but cmake keeps nagging it cannot find the file. 我已经将OPENCV_DIR设置为包含OpenCVConfig.cmake的OpenCV构建文件夹,但是cmake一直在OpenCVConfig.cmake找不到文件。

Could not find a package configuration file provided by "OpenCV" with any of the following names:
  OpenCVConfig.cmake   opencv-config.cmake

Here's my CMakeLists: 这是我的CMakeLists:

cmake_minimum_required(VERSION 3.6)
project(MyProject)

set(OpenCV_DIR "D:/opencv/build/")

find_package(OpenCV REQUIRED core imgproc)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(MyProject main.cpp)
target_link_libraries(MyProject ${OpenCV_LIBS})

And here's the content of the D:/opencv/build/ folder: 这是D:/opencv/build/文件夹的内容:

在此处输入图片说明

What can be the problem here? 这可能是什么问题? Thanks in advance! 提前致谢!

I've found the problem, totally unexpected for a CMake newcomer like me. 我发现了问题,对于像我这样的CMake新手来说,这是完全出乎意料的。

It turns out I installed CMake as part of Cygwin, and thus filesystem paths take the form of /cygdrive/d/opencv/build/ instead. 事实证明,我作为Cygwin的一部分安装了CMake,因此文件系统路径采用/cygdrive/d/opencv/build/ That works without a problem. 那没有问题。

So if you're on Windows, please note the different file path style in case CMake is provided by Cygwin. 因此,如果您使用的是Windows,请注意不同的文件路径样式,以防Cygwin提供CMake。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM