8

我正在尝试使用 cmake 安装 opencv。在 opencv 指令页面中,我找到了以下示例:

cd ~/opencv
mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..

据我了解,我应该使用cmake在我创建的新目录中生成Makefile,在这个例子中应该是~/opencv/release。但我不太明白最后一行。在 cmake 帮助中,我发现:

cmake -D <var>:<type>=<value> = create a cmake cache entry

这是什么意思?尤其是这部分:"<var>:<type>=<value>",我不明白为什么这个例子给出了"CMAKE_BUILD_TYPE=RELEASE""CMAKE_INSTALL_PREFIX=/usr/local .."

非常感谢您的帮助!

4

2 回答 2

7

来自 CMake 文档:

  • -D <var>:<type>=<value>:创建一个 cmake 缓存条目。
    当 cmake 第一次在空的构建树中运行时,它会创建一个 CMakeCache.txt 文件并使用项目的可自定义设置填充它。此选项可用于指定优先于项目默认值的设置。可以根据需要对尽可能多的缓存条目重复该选项。

:<type>可以阅读为可选。

于 2013-11-09T14:42:45.507 回答
2

Maybe you can try:

cd ~/opencv
mkdir release
cd release
cmake -D'CMAKE_BUILD_TYPE=RELEASE' -D'CMAKE_INSTALL_PREFIX=/usr/local'

Just use ' ' surround the parameters and do not leave any blank between -D and ' and it can work.

I encountered some problems when I configure OpenCV with -D parameter.

And I think -D option just change some default parameters for compiling and installing the pkg.

Just as you inferred, CMAKE_BUILD_TYPE=RELEASE means you want to build a "Release" version of the opencv package, and CMAKE_INSTALL_PREFIX=/usr/local means you want to specify the install path of it while using make install command.

于 2013-11-11T05:42:54.330 回答