[CMake] OBJECT_DEPENDS problem

Brad King brad.king at kitware.com
Wed Oct 27 17:21:46 EDT 2004


Alexander Neundorf wrote:

>>Alexander Neundorf wrote: 
>> 
>>
>>>Hi,  
>>>  
>>>it seems I can add only one dependancy to a source file using  
>>>SET_SOURCE_FILES_PROPERTIES()  
>>>E.g. after     
>>>SET_SOURCE_FILES_PROPERTIES(foo.c PROPERTIES OBJECT_DEPENDS test1.c)  
>>>SET_SOURCE_FILES_PROPERTIES(foo.c PROPERTIES OBJECT_DEPENDS test2.c)  
>>>  
>>>After this foo.c only depends on test2.c but not on test1.c, so it 
> 
> seems 
> 
>>>this simply gets overwritten.  
>>>Any ideas how to solve this problem ?  
>>
>> 
>>List all the dependencies as one value: 
>> 
>>SET(foo_c_deps test1.c test2.c) 
>>SET_SOURCE_FILES_PROPERTIES( 
>>   foo.c PROPERTIES OBJECT_DEPENDS "${foo_c_deps}") 
>> 
>>Note the double quotes are used to keep the arguments from getting  
>>separated. 
> 
>  
> Yes, works here :-) 
>  
> The following macro helps if you need to add deps from different places: 
>  
> MACRO(ADD_FILE_DEPENDANCY file) 
>    SET(${file}_deps ${${file}_deps} ${ARGN}) 
>    SET_SOURCE_FILES_PROPERTIES( ${file} 
>       PROPERTIES OBJECT_DEPENDS "${${file}_deps}" ) 
> ENDMACRO(ADD_FILE_DEPENDANCY) 
>  
> ADD_FILE_DEPENDANCY(foo.cpp test1.cpp test2.cpp) 
>  
> and somewhere else: 
>  
> ADD_FILE_DEPENDANCY(foo.cpp moc_foo.cpp) 
>  
> and then foo.cpp depends on all 3 files :-) 

You can also use GET_SOURCE_FILE_PROPERTY to get the old value and then 
append and set it again.

-Brad



More information about the CMake mailing list