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?
option()
possibly selectable incmake-gui
? Are you writing a CMake helper/wrapper function and you want to restrict the values of a passed parameter? Are you trying to prevent aset()
call to a certain variable to get any other then a pre-defined set of values? – Pulchi