CMake如何找到不同版本的lib?

时间:2017-01-12 05:26:44

标签: opencv cmake

我在系统目录(/usr/local)中安装了 Opencv 3.2 ... CMAKE可以自动找到 opencv3.2 。 但是我必须在我的项目中使用 opencv 2.4 ,所以我在~/otherlibs文件夹中安装 opencv 2.4

Cmakefile:

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "~/otherlibs")
find_package(OpenCV 2.4 REQUIRED)

但是CMAKE总是有这样的错误:

CMake Error at CMakeLists.txt:15(find_package):
    Could not find a configuration file for package "OpenCV" that is compatible
    with requested version "2.4"

    The following configuration files were considered but not accepted:
    /usr/local/share/OpenCV/OpenCVConfig.cmake, verison 3.2.0

似乎cmake总是找到系统目录,找到Opencv.cmake后它会停止找到我指定的目录~/otherlibs

1 个答案:

答案 0 :(得分:0)

您是否尝试使用-DCMAKE_PREFIX_PATH=/home/myaccount/otherlibs?这将更改cmake搜索配置文件的规则,可能会对您有所帮助。