cmakecmake-guicmake-language

Constraining Values with ComboBoxes in CMake (cmake-gui)


I encountered CMake project where cache entry in cmake-gui was presented as combobox. But I can't find this project. How to add cache entry to CMakeLists.txt with values constrained with combobox?


Solution

  • You can set the a variable to a default value and add it to the cache.

    set(COLOR_MODE "always" CACHE STRING "Should we use colors")
    

    Then you can set the property for the variable to the list of values you want to appear in the combobox.

    set_property(CACHE COLOR_MODE PROPERTY STRINGS always auto never)