MantisBT - CMake
View Issue Details
0009465CMakeCMakepublic2009-08-31 18:102012-03-06 08:37
Steve King 
Brad King 
normalfeaturealways
closedfixed 
CMake-2-6 
CMake 2.8.4 
0009465: target names should resolve correctly in COMMAND statements
Commands should be able to substitute the target name for build output location of that target. In other words, commands like this fail:

add_executable( foo foo.cpp )
add_custom_command( OUTPUT new_foo COMMAND $(CMAKE_COMMAND) -E copy foo new_foo )

Cmake should recognize 'foo' as a target and implicitly substitute foo's build output.

Currently, the LOCATION property of the target must be used, which is much more cumbersome.
No tags attached.
related to 0011209closed Brad King Support generator expression everywhere they make sense 
related to 0009974closed Brad King CMake should support custom commands that can vary by configuration. 
Issue History
2009-08-31 18:10Steve KingNew Issue
2009-09-11 17:25Bill HoffmanStatusnew => assigned
2009-09-11 17:25Bill HoffmanAssigned To => Bill Hoffman
2009-09-11 17:25Bill HoffmanAssigned ToBill Hoffman => Brad King
2009-09-14 18:24Brad KingNote Added: 0017501
2011-10-05 10:15David ColeRelationship addedrelated to 0011209
2011-10-05 10:15David ColeRelationship addedparent of 0009974
2011-10-05 10:15David ColeRelationship deletedparent of 0009974
2011-10-05 10:16David ColeRelationship addedrelated to 0009974
2011-10-05 10:17David ColeNote Added: 0027525
2011-10-05 12:54David ColeNote Added: 0027526
2011-10-05 12:54David ColeStatusassigned => resolved
2011-10-05 12:54David ColeFixed in Version => CMake 2.8.4
2011-10-05 12:54David ColeResolutionopen => fixed
2012-03-06 08:37David ColeNote Added: 0028819
2012-03-06 08:37David ColeStatusresolved => closed

Notes
(0017501)
Brad King   
2009-09-14 18:24   
CMake does recognize targets if they are the COMMAND executable:

  add_executable(mycopy ...)
  add_custom_command(
    OUTPUT out.txt
    DEPENDS in.txt
    COMMAND mycopy ...
    )

We cannot automatically convert the plain string "foo" in the middle of an argument list...it is ambiguous. However, there does need to be a way to get CMake to replace a token in an argument with information about the target location.

In CMake HEAD from CVS, the add_test() command has a new signature that support a "generator expression" syntax for just this purpose. An argument of this syntax:

  $<TARGET_FILE:myexe>

is replaced with the per-configuration target location which is not known until generate time. I've been meaning to teach add_custom_command about this syntax but it's not yet done. I'll update this issue when it is.
(0027525)
David Cole   
2011-10-05 10:17   
The fix for 0011209 added "generator expressions" to CMake 2.8.4

You may use generator expressions to get target file and directory names using CMake 2.8.4 and later.
(0027526)
David Cole   
2011-10-05 12:54   
This was fixed at the same time as related bug 0011209 - the fix for that one provides a superset of the functionality needed to fix this one...

Use the generator expressions available in 2.8.4 and later to provide custom commands with arguments derived from the target properties.
(0028819)
David Cole   
2012-03-06 08:37   
Closing resolved issues that have not been updated in more than 4 months.