Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to list all CMake build options and their default values?

Tags:

cmake

How can I list cmake default build option in command-line?
I need to build OpenCV libraries from source. Before that, I want to know what are the default build settings.

like image 232
Haris Avatar asked May 31 '13 06:05

Haris


People also ask

How do I use CMake list?

A list in cmake is a ; separated group of strings. To create a list the set command can be used. For example, set(var a b c d e) creates a list with a;b;c;d;e , and set(var "a b c d e") creates a string or a list with one item in it.

Where is CMake list?

Editing CMakeLists Files These can be found in the Auxiliary directory of the source distribution, or downloaded from the CMake Download page.

What does Add_subdirectory do in CMake?

Add a subdirectory to the build. Adds a subdirectory to the build. The source_dir specifies the directory in which the source CMakeLists.


2 Answers

cmake -LA

To list all option( and set( CACHE (cached) variables do:

mkdir build cd build cmake .. cmake -LA | awk '{if(f)print} /-- Cache values/{f=1}' 

Sample stdout:

AUTOGEMM_ARCHITECTURE:STRING=Hawaii BLAS_DEBUG_TOOLS:BOOL=OFF BLAS_DUMP_CLBLAS_KERNELS:BOOL=OFF BLAS_KEEP_KERNEL_SOURCES:BOOL=ON BLAS_PRINT_BUILD_ERRORS:BOOL=O 

The -A switch also show options marked as advanced, so you will likely want to omit it when casually browsing the most useful options.

You may also be interested in adding -H to show more help information about each option as previously mentioned at: https://stackoverflow.com/a/53075317/895245

cmake -LAH 

ccmake ncurses

sudo apt-get install cmake-curses-gui ccmake .. 

shows:

Tested in Ubuntu 16.10, cmake 3.5.2.


You can do cmake -LAH too. The H flag will provide you help for each option.

like image 38
Amir Avatar answered Oct 14 '22 12:10

Amir