2

The CMake option command allows users to define variable from command line:

option(<option_variable> "help string describing option"
     [initial value])

I am wondering how to view all such available options. I.e. I am looking for something like ./configure -h where it typically shows a summary all possible configuration a user can tweak.

James
  • 133
  • 7
  • Does this answer your question? [How to list all CMake build options and their default values?](https://stackoverflow.com/questions/16851084/how-to-list-all-cmake-build-options-and-their-default-values) – starball Sep 05 '22 at 19:12

1 Answers1

1

There is no such feature for a simple reason - command option is not always evaluated. E.g.:

if(WIN32)
  option(WIN32_TESTS "Build windows specific tests" OFF)
endif()

So you need to run cmake anyway, then you can view options in CMakeCache.txt file directly or using cmake-gui (or ccmake).

Of course you can print the messages manually:

message("Build configuration:")
message("  C++ flags: ${CMAKE_CXX_FLAGS}")
if(WIN32)
  message("  WIN32_TESTS: ${WIN32_TESTS}")
endif()