[CMake] Feature wish - constrained string values for configuration options

Philip Lowman philip at yhbt.com
Sat Jul 19 02:21:22 EDT 2008


On Fri, Jul 18, 2008 at 1:40 PM, Bill Hoffman <bill.hoffman at kitware.com>
wrote:

> Alexander Neundorf wrote:
>
>> On Friday 18 July 2008, Michael Wild wrote:
>>
>>> On 18Jul, 2008, at 12:27, Robert Haines wrote:
>>>
>>>> I would like to point at my feature wish:
>>>>> http://www.vtk.org/Bug/view.php?id=7313
>>>>>
>>>>> Opinions?
>>>>>
>>>> I was looking for this functionality the other day, I think it's a
>>>> good idea. I had thought that it was already in there for the
>>>> CMAKE_BUILD_TYPE option that you always get but that seems to be
>>>> implemented in a different way.
>>>>
>>>> So +1 from me. Is there anyway I can reflect that in the bug tracker?
>>>>
>>> That would be a very desirable feature. I suggest this be split even
>>> further: options with fixed values, like what you get from drop-down
>>> menus and options with a set of "proposals", as you get in a combo-box.
>>>
>>> definitely +1
>>>
>>
>> This seems to be a duplicate of
>> http://public.kitware.com/Bug/view.php?id=1527 , which is a duplicate of
>> bug 39 according to the note, but I can't find bug 39 anymore :-/
>>
>>
> Yup, this is a very old feature request...
>
> However, it is not that easy to implement, since the basic type in CMake is
> a string.  There is no way to constrain the value of a variable, or even
> store more information about a variable.


Wouldn't it be possible to do something like this primarily in the Cache,
simply make a new cmCacheManager::CacheEntryType called ENUM (or something
similar):

CMAKE_BUILD_TYPE:ENUM=0,Debug,Release,MinSizeRel,RelWithDebInfo  # Debug is
selected
CMAKE_BUILD_TYPE:ENUM=3,Debug,Release,MinSizeRel,RelWithDebInfo  #
RelWithDebInfo is selected

Then simply modify cmCacheManager::GetCacheValue() to be ENUM-aware and
return the proper string based on the index.  Obviously I'm oversimplifying
things here since all of the GUIs would need to be modified to be
ENUM-aware, validation on assignment of the cache variable would have to
occur, and the user would have to be given the means to define allowable
enumerations via SET() or a command similar to OPTION().  It doesn't seem
like that much work if you're willing to accept the limitation that
enumerated values would only be valid in the cache.

Is the crux of this problem basically in trying to figure out how to
validate someone doing "cmake -DCMAKE_BUILD_TYPE..." prior to the creation
of a cache variable?

-- 
Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20080719/e4a0c71e/attachment-0001.htm>


More information about the CMake mailing list