[cmake-developers] TARGET property LOCATION

Daniel Pfeifer daniel at pfeifer-mail.de
Mon Dec 2 03:46:31 EST 2013


2013/12/2 Nils Gladitz <nilsgladitz at gmail.com>:
> On 12/02/2013 09:19 AM, Marcel Loose wrote:
>>
>> What would be the preferred way to pass the location of a built executable
>> target to ADD_TEST? By using the COMMAND option of ADD_TEST, or by using the
>> $<TARGET_FILE> generator expression? Best regards, Marcel Loose.
>
> My personal preference would be the NAME/COMMAND signature of add_test().
> I might use the generator expression when the test command would require the
> output file as a parameter (e.g. in case you wrap your test with some sort
> of launcher).

I always use the $<TARGET_FILE> generator expression in add_test(). It
makes the code more robust:
When someone changes the target name (or when there is a typo), the
generator expression cannot be evaluated and an error is reported at
configure time.
When the target name is used without a generator expression, typos can
lead to strange testing results.

cheers, Daniel



More information about the cmake-developers mailing list