Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cmake -D <var>:<type>=<value> what does the parameter "-D" mean

Tags:

c++

opencv

cmake

I'm trying to use cmake to install opencv. In the opencv instruction page, I find the following example:

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

As I understand it, I should use cmake to generate Makefile in the new directory I created, which in this example should be ~/opencv/release. But I don't quite understand the last line. In cmake help, I find:

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

What does it mean? Especially this part: "<var>:<type>=<value>", I don't understand why the example gives "CMAKE_BUILD_TYPE=RELEASE" and"CMAKE_INSTALL_PREFIX=/usr/local .."

Your help is greatly appreciated!

like image 985
CathIAS Avatar asked Nov 09 '13 14:11

CathIAS


2 Answers

From the CMake Documentation:

  • -D <var>:<type>=<value>: Create a cmake cache entry.
    When cmake is first run in an empty build tree, it creates a CMakeCache.txt file and populates it with customizable settings for the project. This option may be used to specify a setting that takes priority over the project's default value. The option may be repeated for as many cache entries as desired.

The :<type> could be read as optional.

like image 78
πάντα ῥεῖ Avatar answered Nov 19 '22 23:11

πάντα ῥεῖ


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.

like image 2
Zhao Zhang Avatar answered Nov 20 '22 00:11

Zhao Zhang