0

嗨,我编写了一个基本程序来打开图像文件。我正在尝试使用 CMake 来编译它。这就是我的 CMake 文件的样子:

         cmake_minimum_required(VERSION 2.6)
         project( textures )
         find_package( OpenCV REQUIRED )
         add_executable( textures textures.cpp )
         target_link_libraries( textures ${OpenCV_LIBS} ) 

当我运行“cmake .”时,出现以下错误。

         CMake Error at CMakeLists.txt:3 (find_package):
         By not providing "FindOpenCV.cmake" in CMAKE_MODULE_PATH this project has
         asked CMake to find a package configuration file provided by "OpenCV", but
         CMake did not find one.

         Could not find a package configuration file provided by "OpenCV" with any
         of the following names:

         OpenCVConfig.cmake
         opencv-config.cmake

         Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
         "OpenCV_DIR" to a directory containing one of the above files.  If "OpenCV"
         provides a separate development package or SDK, be sure it has been
         installed.


         -- Configuring incomplete, errors occurred!

关于这意味着什么以及如何解决它的任何想法?谢谢。

4

1 回答 1

0

CMake 正在寻找文件 FindOpenCV.cmake,因此请确保您拥有该文件(您可以在线搜索其他人的实现)。然后将此文件放在正确的目录中,并在 CMakeLists.txt 文件中的项目行之后添加此命令”

 set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/relative/path/to/your/file/")

其中 CMAKE_SOURCE_DIR 是您的源代码所在的位置。

于 2013-02-13T21:04:54.740 回答