[CMake] appending values to properties

Brad King brad.king at kitware.com
Thu Jan 26 11:17:32 EST 2006


Alexander Neundorf wrote:
> Hi,  
>   
> there are properties like OBJECT_DEPENDS and ADDITIONAL_MAKE_CLEAN_FILES.  
> Add entries to them is quite tedious:  
>   
> GET_SOURCE_FILE_PROPERTY(_depends file.cpp OBJECT_DEPENDS)  
> IF(_depends)  
>    SET(_depends ${_depends} anotherdependfile.h)  
> ELSE(_depends)  
>    SET(_depends anotherdependfile.h)  
> ENDIF(_depends)  
> SET_SOURCE_FILES_PROPERTIES(file.cpp PROPERTIES OBJECT_DEPENDS  
> ${_depends} )  
>   
> The IF test is required because if the property hasn't been set yet, it  
> has the value "NOTFOUND" instead of empty.  
>   
> I have two suggestions:  
> -make the returned variable empty instead of "NOTFOUND" -> might be  
> incompatible  
>   
> -add an option to SET_XXX_PROPERTIES() "APPEND" or something like this,  
> so that one could simply do:  
> SET_SOURCE_FILES_PROPERTIES(file.cpp APPEND PROPERTIES OBJECT_DEPENDS  
> anotherdependfile.h )  
>  
> What do you think ?  

I think APPEND is the cleaner approach.  However, we have to distinguish 
between appending to a string and appending to a list because some 
properties are strings and some are lists.  The SET_*_PROPERTIES 
commands do not actually interpret the properties and do not know which 
are which.

How does this look:

SET_SOURCE_FILES_PROPERTIES(file.cpp APPEND_LIST PROPERTIES
  OBJECT_DEPENDS anotherdependfile.h
)

?

> Are files marked as "OUTPUT" in a CUSTOM_COMMAND actually automatically  
> added the the list of files which will be deleted on "make clean" ?  

Yes.

-Brad


More information about the CMake mailing list