[CMake] add_test to support generator expressions?

Nils Gladitz nilsgladitz at gmail.com
Tue Oct 27 15:28:38 EDT 2015


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.

Without the generator expression reading the property at configuration 
time is not really an option because the test's properties will not 
exist before add_test() and the test command itself is what was 
referring to that property.

You'd have to reorder logic so that the parameter for --skip-return-code 
is known before add_test() (and use e.g. variables or (custom) target 
properties).

Nils



More information about the CMake mailing list