CMakeLists.txt中的CMake错误CMAKE_PREFIX_PATH

时间:2014-11-25 12:46:03

标签: opencv cmake

我已从http://face.ci2cv.net/下载了脸部分析SDK的源代码。现在我想让它运行起来。我下载了所有必要的软件并按照安装说明进行操作。当我尝试执行cmake [options]时......我收到错误。

CMake Error at CMakeLists.txt:21(find_package):
Could not find a package configuration file provided by "OpenCV" with any of the following names:
OpenCVConfig.cmake
opencv-comfig.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. 

CMakeLists.txt看起来像这样

# -*-cmake-*-
PROJECT(CSIRO-FaceAnalysis-SDK)

cmake_minimum_required(VERSION 2.8)

#set(CMAKE_VERBOSE_MAKEFILE true)

# Default values for options
if(NOT DEFINED OpenCV_PREFIX)
  set(OpenCV_PREFIX ${CMAKE_INSTALL_PREFIX})
endif()


  set(OpenCV_PREFIX C:/Program Files/Development/opencv/build)
endif(
# Configurable options
OPTION(WITH_GUI "Build the GUI" OFF)

# Third party libraries
find_package(OpenCV REQUIRED core highgui imgproc objdetect
  PATHS ${OpenCV_PREFIX}/lib/cmake/
        ${OpenCV_PREFIX}/share/OpenCV/
  NO_DEFAULT_PATH) # For some reason CMake uses its defaults before the above paths.

请帮助我,我不知道该怎么做。

谢谢,B

2 个答案:

答案 0 :(得分:8)

  1. 检查系统上是否安装了OpenCV。请注意安装它的文件夹。例如:C:\OpenCV
  2. 使用类似于
  3. 的命令行执行CMake
      

    cmake -DCMAKE_PREFIX_PATH =“C:\ OpenCV”..

    OR

    找到包含OpenCVConfig.cmake的文件夹(例如C:\ OpenCV \ build \ x86 \ vc10 \ lib)并通过变量OpenCV_DIR将其传递给CMake

      

    cmake -DOpenCV_DIR =“C:\ OpenCV \ build \ x86 \ vc10 \ lib”..

    在这两种情况下,我认为您尝试编译的代码提供程序通过将NO_DEFAULT_PATH放入find_package(OpenCV ...)来提交错误。如果无效,请在删除此标志后重试。

答案 1 :(得分:1)

几天前我遇到了同样的问题,这是我用来将它安装到我的系统上的代码,并使 CMakeLists.txt 了解如何定位这些文件。此过程也适用于其他软件包。

cd ~/

git clone https://github.com/opencv/opencv.git

cd opencv

mkdir install

cd install

cmake ../

make

sudo make install

注意:由于其复杂性和大小,opencv 需要很长时间才能制作,但我确信有一种方法可以下载并仅制作您需要的某些部分。我没有这样做,因为我不知道怎么做。