[CMake] add_test to support generator expressions?

Chris Green greenc at fnal.gov
Tue Oct 27 09:33:28 EDT 2015


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?

Thanks for the clarification,

Chris.

On 10/26/15 3:20 PM, Nils Gladitz wrote:
> On 26.10.2015 20:29, Chris Green wrote:
>> Hi,
>>
>> I have a function cet_test(), which allows a user to specify the 
>> details of a test which will be executed via a wrapper, 
>> cet_exec_test. It calls the CMake add_test() macro to set this up. 
>> The user may subsequently set the SKIP_RETURN_CODE property on this 
>> test, which must be communicated to cet_exec_test() so that it can 
>> notify CMake if the test requirements are violated. I attempted to do 
>> this with:
>>
>> add_test(NAME ${target}
>>      ...
>>      COMMAND cet_exec_test ... --skip-return-code 
>> $<TARGET_PROPERTY:${target},SKIP_RETURN_CODE>
>>      ...)
>>
>> but this resulted in an error. Am I using generator expressions 
>> wrongly in this case, or does add_test() not support them? Is there 
>> something else I can do?
>
> You did not mention what the error actually is but ...
>
> add_test() does support generator expressions in the command (as long 
> as you are using the NAME/COMMAND signature; which you are).
> Tests are not targets; hence TARGET_PROPERTY does not work here unless 
> you also happen to have an actual target with the same name as the 
> test (which is possible but can't be inferred from your snippet) and 
> you set the property of that target rather than the test.
>
> Nils
>

-- 
Chris Green <greenc at fnal.gov>, FNAL CS/SCD/ADSS/SSI/TAC;
'phone (630) 840-2167; Skype: chris.h.green;
IM: greenc at jabber.fnal.gov, chissgreen (AIM),
chris.h.green (Google Talk).



More information about the CMake mailing list