new cmake macro available (starting monday): MACRO_APPEND_IF()

Matt Williams matt at
Sun Dec 16 14:09:55 GMT 2007

On Sunday 16 December 2007 13:29:06 Alexander Neundorf wrote:
> Hi,
> I added a new macro MACRO_APPEND_IF(var condition value1..valueN) to
> kdelibs.
> Typical use is like this, instead of:
>   set(mySrcs ${mySrcs} file1.cpp file2.cpp)
> you can now do:
> macro_append_if(mySrcs SOMETHING_FOUND file1.cpp file2.cpp)
> I am not sure about the following things and like to get some comments on
> them:
> -the order of the arguments: keep it as is (first list variable, then
> condition) or exchange these two ?

I think that macro_append_if(SOMETHING_FOUND mySrcs file1.cpp file2.cpp) is 
better since it more clearly shows the link between the 'if' and 
the 'SOMETHING_FOUND'. Also, it more closely follows the order in which the 
variables are used in the old, verbose version (first do the 
if(SOMETHING_FOUND), then say mySrcs += file1.cpp...).

> -the macro always appends as list, not as string, but this is not really
> obvious from the name. OTOH until now I never needed a macro like this for
> appending something to strings, I always needed it for lists (of source
> files, libraries etc.)
> -a different name could be macro_optional_append(), which is a bit more
> typing, but would it be  better ?

I think making it clear that it's a sort of if() statement is more clear to 
the user.

> Bye
> Alex

More information about the kde-core-devel mailing list