ChatGPT解决这个技术问题 Extra ChatGPT

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

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.

Try the GUI (cmake-gui)?

C
Ciro Santilli Путлер Капут 六四事

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.


OP asked for ALL options - for that one needs cmake -LA.
@PrzemekD thanks, mentioned it in the answer. Clients don't always know what is best for them :-)
Well... those are the options relevant to the project. How can you list all POSSIBLE options?
@banderlog013 maybe it is because that is a general CMake option and not added specifically by OpenBLAS: cmake.org/cmake/help/v3.0/variable/BUILD_SHARED_LIBS.html
@CiroSantilli新疆改造中心法轮功六四事件 makes sense, but then how I could get values of standard options? Also, Will it work if I have cmake files in subdirs (~nested cmake)?
A
Amir

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


This only lists options as a by-product of doing many other things, for example if called like this it would clutter the root folder with extra files. Better use in form cd build && cmake -LAH ...
t
tune2fs

I do not know of an direct way to do it.

A way around this is to edit the main CMakeLists.txt and print at the end of the file the settings you are interested. The Variables where the most important cmake setting are stored are listed here:

I always print these variables at the end of my CMakeLists.txt to see the settings.

MESSAGE(STATUS "Build type: " ${CMAKE_BUILD_TYPE})
MESSAGE(STATUS "Library Type: " ${LIB_TYPE})
MESSAGE(STATUS "Compiler flags:" ${CMAKE_CXX_COMPILE_FLAGS})
MESSAGE(STATUS "Compiler cxx debug flags:" ${CMAKE_CXX_FLAGS_DEBUG})
MESSAGE(STATUS "Compiler cxx release flags:" ${CMAKE_CXX_FLAGS_RELEASE})
MESSAGE(STATUS "Compiler cxx min size flags:" ${CMAKE_CXX_FLAGS_MINSIZEREL})
MESSAGE(STATUS "Compiler cxx flags:" ${CMAKE_CXX_FLAGS})

a more detail answer can be found here : stackoverflow.com/questions/24767450/…