[CMake] add_test to support generator expressions?

Stephen Kelly steveire at gmail.com
Tue Oct 27 15:49:07 EDT 2015


Nils Gladitz wrote:

> On 27.10.2015 19:58, Stephen Kelly wrote:
>> Chris Green wrote:
>>
>>> Ah, I see. It appears I was unclear on the difference between target and
>>> test. What I actually want is the *test* property SKIP_RETURN_CODE,
>>> which there does not seem to be any way to access via a generator
>>> expression. Looks like I'm out of look, unless this is an upcoming
>>> feature?
>> Generator expressions are generally only useful for things which are
>> determined at generate-time.
>>
>> Can't you just read the test property at configure-time instead? You're
>> the one setting the property, right?
> 
> Deferring evaluation to generation time does have the advantage that you
> can set and change properties at any point after the test has been
> created and you can still be sure that the test is invoked with the
> final value.

Right. What I missed is that Chris seems to be making an interface for other 
unknown downstreams to use (a cet_test function).

It would be possible to require the user of cet_test to specify the 
SKIP_RETURN_CODE in a parameter, but there would be unexpected behavior if 
someone omitted that parameter and wrote 

 cet_test(mytest ...)
 set_test_property(mytest PROPERTIES SKIP_RETURN_CODE ...)

instead.

A lot of effort went into cmake targets to make wrappers like 
kde4_add_executable/kde4_add_library unnecessary, and generator expressions 
were a part of that. 

Perhaps it makes sense to put similar effort into making add_test wrappers 
unnecessary, and generator expressions for test properties could be part of 
that. 

However, I don't have so much experience with doing beyond-basic things with 
ctest, so I don't know what kinds of issues arise which lead people to 
create wrappers like that, so I probably can't be of much help.

Thanks,

Steve.




More information about the CMake mailing list