CMake find_package for OpenCV

目标:

编译background subtraction library

问题:

Could not find module Findopencv.cmake or a configuration file for package

opencv.


Adjust CMAKE_MODULE_PATH to find Findopencv.cmake or set opencv_DIR to the

directory containing a CMake configuration file for opencv. The file will

have one of the following names:


opencvConfig.cmake

opencv-config.cmake

原因:

bgs中的CMakeLists用find_package(opencv REQUIRED)来定位opencv。新版本OpenCV用FindOpenCV.cmake的命名规则(module mode),或者OpenCVConfig.cmake(config mode)。

解决:

bgs的CMakeLists中,opencv--->OpenCV!!!

cmake 自动找到 /usr/local/share/OpenCV/OpenCVConfig.cmake。

本机上有两个opencv版本。/usr/local/share/OpenCV/OpenCVConfig.cmake (2.4.6) 和/usr/local/share/opencv/OpenCVConfig.cmake (2.1.0 zombie)


更多

CMake:How To Find Libraries

http://www.cmake.org/Wiki/CMake:How_To_Find_Libraries


cmake_minimum_required(VERSION 2.8)
set(Boost_INCLUDE_DIR /usr/local/src/boost_1_46_1)
set(Boost_LIBRARY_DIR /usr/local/src/boost_1_46_1/stage/lib)
find_package(Boost COMPONENTS system filesystem REQUIRED)
include_directories(${Boost_INCLUDE_DIR})
link_directories(${Boost_LIBRARY_DIR})

add_executable(main main.cpp)
target_link_libraries( main ${Boost_LIBRARIES} )

你可能感兴趣的:(OpenCV备忘)