[CMake] add_custom_command and $<...>

Jaime Frey jfrey at cs.wisc.edu
Wed Oct 5 10:09:27 EDT 2011


On Oct 4, 2011, at 6:56 PM, Michael Hertling wrote:

> On 10/04/2011 09:20 PM, Jaime Frey wrote:
>> Hi.
>> I'm having some trouble with the add_custom_command() function in cmake 2.8.3. I'm using it to run a POST_BUILD command on a target. The docs say I can use $<TARGET_FILE:tgt> in the arguments to COMMAND to get the filename of the generated target file. But no substitution occurs and "$<TARGET_FILE:tgt>" gets plopped into the generated makefiles, where make happily replaces $< with one of the dependencies and the build fails.
>> 
>> Bug 9465 (http://public.kitware.com/Bug/view.php?id=9465) suggests that $<...> in add_custom_command() hasn't been implemented, but the ticket is 2 years old now. I don't see any mention of this in the Changelog for versions after 2.8.3.
>> 
>> Am I missing something, or are the docs in error?
> 
> AFAIK, generator expressions for custom commands have been introduced in
> 2.8.4. A possible error - rather an omission - in the documentation is
> that they also work for custom targets which isn't mentioned at all.


Thanks.
I see the entry in the Changelog now. I guess I didn't pick the right search term when I looked at it before. Might I suggest adding a note to  bug 9465 that the custom commands now support generator expressions (bug 11209), for any future searchers who run across it?

+--------------------------------+-----------------------------------+
|           Jaime Frey           | I used to be a heavy gambler.     |
|       jfrey at cs.wisc.edu        | But now I just make mental bets.  |
|                                | That's how I lost my mind.        |
+--------------------------------+-----------------------------------+



More information about the CMake mailing list