[CMake] set_property() scope qualifier question...

Sean Chittenden sean at chittenden.org
Mon Jun 1 14:12:52 EDT 2009


>> Ideally I'd like to see cmake(1) be able to issue the following  
>> commands:
>>
>> // Create foo_test
>> gcc -o foo.o -c foo.c -DTESTING
>> gcc -o foo_test foo.o
>>
>> // Create bar_test
>> gcc -o foo.o -c foo.c
>> gcc -o bar.o -c bar.c -DTESTING
>> gcc -o bar_test foo.o bar.o
>>
>>
>> That help clarify?  set_target_property() still defines TESTING for  
>> both foo.c and bar.c and the bar_test case would break.  Ideally  
>> I'd like to set a source property in the bar_test case, but don't  
>> know how to do that.  I thought the scope property would do it.   
>> Can I somehow finagle this using an if() ?
>
> Not that I know of.

Drat.  Well...  guess this is a feature request then: being able to  
set properties on a per source and per target (or test).  :~]

> How about
> set_property(TARGET foo_test APPEND PROPERTY COMPILE_FLAGS "- 
> DTESTING_FOO")
> set_property(TARGET bar_test APPEND PROPERTY COMPILE_FLAGS "- 
> DTESTING_BAR")


My use of patch(1) does exactly that, let's me use -DTESTING_FOO and - 
DTESTING_BAR.  I find that to be less than ideal and thought that I  
was missing something or wasn't aware of a trick using if() or some  
other something.

Thanks in advance and thanks for cmake(1).  I'm very happy not using  
auto* anymore (though I wish there was a "create an sh(1) script mode  
for source distributions" when distributing source tar files).  -sc


--
Sean Chittenden
sean at chittenden.org





More information about the CMake mailing list