[CMake] elseif request
David C Thompson
dcthomp at sandia.gov
Mon Sep 18 18:33:50 EDT 2006
Brad King wrote:
> Alan W. Irwin wrote:
> > So far all but one of those who responded to the discussion are in support
> > of the idea, but it is also fair to say that only a handful of subscribers
> > to this list have responded yet.
> >
> > I am particularly interested in the opinion of Bill Hoffman, Brad King, and
> > other developers of CMake since they are the ones who would have to do the
> > implementation. If they are reasonably positive about the idea, I will
> > write this up as a wish-list bug report to give a clear point of reference
> > for the change.
>
> This is a reasonable request. I'll have to discuss it with the other
> developers but it is at least worth putting in the bug tracker. Please
> put in the request. At least then the final discussion will be
> documented in an easy-to-reference place.
What if you named the construct something other than ELSEIF? For
instance:
ONEOF( LABEL )
CONDITION( cond_1 )
statements here if cond_1 is true
OR_CONDITION( cond_2 )
statements here if cond_1 is false and cond_2 is true
... (more OR_CONDITION statements possible) ...
OTHERWISE()
statements here if cond_1 and cond_2 are false
ENDONEOF( LABEL )
The LABEL would simply be a comment. The only mildly misleading part is
that cond_2 is not *exactly* the condition under which the associated
block of statements are executed (it's really cond_2 AND NOT cond_1).
But using "OR_CONDITION" instead of "CONDITION" for subsequent clauses
reduces the chance of confusion. An example might be:
ONEOF( FileTypeCheck )
CONDITION( FILENAME MATCHES ".txt" )
SET( FILE_TYPE 1 )
OR_CONDITION( FILENAME MATCHES ".bin" )
SET( FILE_TYPE 2 )
OR_CONDITION( FILENAME MATCHES ".foo" )
SET( FILE_TYPE 3 )
OTHERWISE()
SET( FILE_TYPE -1 )
ENDONEOF( FileTypeCheck)
Just my 2 cents,
David
More information about the CMake
mailing list