使用CMake在OpenCV-2.4.3中编译

时间:2013-02-13 18:43:01

标签: opencv cmake

您好我已经编写了一个打开图像文件的基本程序。我正在尝试使用CMake来编译它。 Thsi是我的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!

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

1 个答案:

答案 0 :(得分:0)

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

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

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