[CMake] elseif request

Alan W. Irwin irwin at beluga.phys.uvic.ca
Sun Sep 17 21:49:50 EDT 2006


On 2006-09-17 17:47-0700 Philip Lowman wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Sat, Sep 16, 2006 at 01:39:57PM -0700, Alan W. Irwin wrote:
>> if(cond1)
>>   block of statements
>> elseif(cond2)
>>   block of statements
> <snip>
>> elseif(condn)
>>   block of statements
>> else(cond1)
>>   block of statements
>> endif(cond1)
>>
>> original proposal for all other languages.  So my order of preference is (1)
>> my original proposal, (2) the status quo, and (last) the alternative
>> proposal you seem to be advocating.
>
> I'm new to cmake but I think the addition of an elseif() option would be
> extremely useful.  Alan's proposed syntax seems optimal to me provided
> it can be combined with the CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS option
> (that someone else pointed out on here).
>
> Requiring the user to specify "else(cond1)" and "endif(cond1)" may
> prevent a few mistakes but it also gets kinda annoying as conditionals
> get longer or change.

Agreed.  I wish I had known about that CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS
variable before the CMake build system was completed for PLplot.  It would
have made my life a whole lot easier.  I don't need the closing specific
conditions in the else() and endif() statements because I keep track of if
block nesting with indentation.

I am new to CMake myself (first started using it in July) so I feel
diffident about suggesting a language extension, but I decided to start this
"elseif" discussion since virtually every computer language I deal with has
that type of construct to simplify block if syntax, and to me, it seems a
no-brainer to add this type of construct to the CMake language as well.

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.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the Yorick front-end to PLplot (yplot.sf.net); the
Loads of Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the CMake mailing list