[CMake] add_test to support generator expressions?

Nils Gladitz nilsgladitz at gmail.com
Mon Oct 26 16:20:30 EDT 2015


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



More information about the CMake mailing list