[CMake] Re: CMake and Lua

Brandon Van Every bvanevery at gmail.com
Fri Feb 29 13:03:17 EST 2008


On Fri, Feb 29, 2008 at 9:55 AM, Philip Lowman <philip at yhbt.com> wrote:
>
>
>
> On Fri, Feb 29, 2008 at 8:57 AM, Rodolfo Schulz de Lima
> <rodolfo at rodsoft.org> wrote:
> > Bill Hoffman escreveu:
> >
> > > So what exactly about the CMake language gives you this feel?
> >
> > Hi, let me just add my opinion on this one. I really think that in a if
> > clause, having to repeat the condition in the else, elseif and endif is
> > a little too much verbose for my taste. The following snippet
> > illustrates this issue
> >
> > IF(NOT ${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
> >     set(outofbuild true)
> > ELSE(NOT ${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
> >     set(outofbuild false)
> > endif(NOT ${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR}
> >
> > I know that we can disable this *feature*, but it isn't default. I know
> > you did this to help programmers know which 'if' an 'endif' is related,
> > but this kind of thing is normally done with comments. And in my example
> > above since each branch has one line, the verbosity is unnecessary.
>
>
> I wholeheartedly agree.  I don't think people realize how unreadable,
> unmaintainable, and confusing this "feature" really is.
>
> It's unreadable because you have to read the same crap over and over again
> (occupying at least 3 lines, sometimes 6 depending on how complex the
> conditional is).

The problem is, there's an impedance mismatch between short and long
contexts.  The repetition is *very* readable and helpful when the
branch is long enough that you have to scan through 20 lines of code
to see what's going on.  Would it be a sin to require that if..else
statements more than 20 lines apart have matching clauses?  I suppose
that could end up being a PITA for macros expanding within macros, as
the line lengths could easily change.  But it's tempting to have one's
cake and eat it too.  I don't buy the "do it with comments" approach.
Something changes, then the comments are wrong.  That's why CMake
throws an error when you change a clause and they don't match.

I grudgingly admit that in terms of marketing prejudice, most
newcomers will hate the repetition.  I think that's blind prejudice on
their part and that the repetition has technical merit.  But I agree
it doesn't have marketing merit.

> It's unmaintainable because every time you make the slightest modification
> to your original IF() statement you have to modify both ELSE() and ENDIF().

That's not unmaintainable, that's forced maintenance.  Compilers give
warnings and throw errors, it's no different.


Cheers,
Brandon Van Every


More information about the CMake mailing list