I'm working on a project which is built with CMake, so I'm writing up a CMakeLists.txt
for it. In this file I want to have a (cached) CMake variable that can only take one of several options (which I would specify somehow), rather than any arbitrary string. For simplicity, let's take it to be a string which can take "red", "green" or "blue" - but nothing else.
Can I achieve this with a recent CMake version, other than setting an arbitrary string then checking it for validity?
The answer is to be found in one of Kitware's Blog Posts named "Constraining Values with ComboBoxes in CMake (cmake-gui)":