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

Alexander Neundorf neundorf at kde.org
Sun Dec 16 13:29:06 GMT 2007


Hi,

I added a new macro MACRO_APPEND_IF(var condition value1..valueN) to kdelibs.

Typical use is like this, instead of:

if(SOMETHING_FOUND)
  set(mySrcs ${mySrcs} file1.cpp file2.cpp)
endif(SOMETHING_FOUND)

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 ?

-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 ?

Bye
Alex




More information about the kde-core-devel mailing list