new cmake macro available (starting monday): MACRO_APPEND_IF()
Andreas Hartmetz
ahartmetz at gmail.com
Sun Dec 16 19:45:42 GMT 2007
Am Sonntag 16 Dezember 2007 18:05:22 schrieb Alexander Neundorf:
> On Sunday 16 December 2007, David Faure wrote:
> ...
>
> > Is this really worth it? The if/set/endif lines are clear and
> > human-readable, while macro_append_if sounds like "there's some magic
> > involved here, including some condition and some appending" but without
> > being as clear for the casual reader, IMHO. Not a strong veto, just
> > wondering...
>
> If you have many such statements, it can get quite long. E.g. 10 times
> would be 40 vs. 10 loc, which are easier to overview.
>
> if(SOMETHING_FOUND)
> set(mySrcs ${mySrcs} file1.cpp file2.cpp)
> endif(SOMETHING_FOUND)
>
> if(FOO_FOUND)
> set(mySrcs ${mySrcs} foo.cpp)
> endif(FOO_FOUND)
>
> if(BAR_FOUND)
> set(mySrcs ${mySrcs} bar.cpp)
> endif(BAR_FOUND)
>
> vs.
>
> macro_append_if(SOMETHING_FOUND mySrcs file1.cpp file2.cpp)
> macro_append_if(FOO_FOUND mySrcs foo.cpp)
> macro_append_if(BAR_FOUND mySrcs bar.cpp)
>
First off, I know next to nothing about the CMake macro language.
Is it possible to make a generic one-line if?
I am strongly against something that looks more special than it is because it
forces you to consider what special things it might do. It's especially
frustrating when you look it up and the answer is "actually nothing". A
generic one-line if is clearer (it can't possibly do anything special if the
designer was not on crack) and, of course, more widely applicable.
More information about the kde-core-devel
mailing list