具体来说,我想将my/path/to/opencv/release中的opencv包括在内,而不是在/usr/local/include中构建系统的opencv lib来构建我自己的opencv。如何设置cmake来实现此目的?我正在使用Ubuntu 14.04。

最佳答案

为了提供一个示例,下面是Luajit库的Find-CMake文件。您的CMake项目中可能有一个类似“FindOpenCV.cmake”的文件。它很可能具有手动添加的默认安装路径,例如:“/usr/include/luajit-2.0 /usr/local/include/luajit-2.0”,您可以将这些DIR更改为所需的安装目录。如果默认路径包含在变量中,则可以找到该变量的定义并进行更改(最好通过配置选项),或者用字符串覆盖它。

# Try to find Lua or LuaJIT depending on the variable ENABLE_LUAJIT.
# Sets the following variables:
#   LUA_FOUND
#   LUA_INCLUDE_DIR
#   LUA_LIBRARY
#

SET (LUA_FOUND FALSE)

SET (LUA_INTERPRETER_TYPE "")

SET (LUA_INTERPRETER_TYPE "LuaJIT")
SET (LUA_LIBRARY_NAME luajit-5.1)
SET (LUA_INCLUDE_DIRS /usr/include/luajit-2.0 /usr/local/include/luajit-2.0)

FIND_PATH (LUA_INCLUDE_DIR lua.h ${LUA_INCLUDE_DIRS}
            HINT ${LUAJIT_INCLUDE_DIR_HINT}/include)
FIND_LIBRARY (LUA_LIBRARY NAMES ${LUA_LIBRARY_NAME} PATHS /usr/lib /usr/local/lib
            HINT ${LUAJIT_INCLUDE_DIR_HINT}/bin)

#...

MARK_AS_ADVANCED ( LUA_INCLUDE_DIR LUA_LIBRARY)

10-08 20:02