我通过Homebrew安装了OpenCV和OpenCV3。
OpenCV已链接,可通过cmake
访问/usr/local/share/OpenCV
OpenCV3未链接且位于此处
/usr/local/Cellar/opencv3/3.0.0
我有这个CMakeLists.txt
文件:
cmake_minimum_required(VERSION 2.8)
project( DisplayImage )
find_package( OpenCV REQUIRED )
add_executable( DisplayImage DisplayImage.cpp )
target_link_libraries( DisplayImage ${OpenCV_LIBS} )
当我运行cmake
时,它使用OpenCV的第一个版本。
如何告诉cmake
使用第二个包?
更新
我试着指定
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "/usr/local/Cellar/opencv3/3.0.0/share/OpenCV")
find_package( OpenCV REQUIRED )
和
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "/usr/local/Cellar/opencv3/3.0.0/share/")
find_package( OpenCV REQUIRED )
但在CMakeCache.txt
中,我仍然看到了这一点:
OpenCV_CONFIG_PATH:FILEPATH=/usr/local/share/OpenCV
这又不是我需要的......
谢谢。
答案 0 :(得分:2)
有几种选择。
选项1
使用:
CMAKE_PREFIX_PATH=/usr/local/Cellar/opencv3 cmake ...
选项2
替换
find_package( OpenCV REQUIRED )
与
find_package(OpenCV HINTS /usr/local/opt/opencv3 /usr/local/Cellar/opencv3 REQUIRED)
答案 1 :(得分:1)
尝试取消链接opencv并链接opencv3:
> readlink /usr/local/share/OpenCV
../Cellar/opencv/2.4.11_2/share/OpenCV
> brew unlink opencv
> brew link opencv3 --force
> readlink /usr/local/share/OpenCV
../Cellar/opencv3/3.0.0/share/OpenCV
否则,您可能希望为CMake设置适当的变量:http://www.cmake.org/Wiki/CMake_Useful_Variables