View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0012877CMakeCMakepublic2012-01-16 03:492013-06-03 09:05
ReporterPetr Kmoch 
Assigned To 
PrioritynormalSeverityminorReproducibilityN/A
StatusclosedResolutionduplicate 
PlatformOSOS Version
Product VersionCMake 2.8.6 
Target VersionFixed in Version 
Summary0012877: Support generator expressions in OUTPUT
DescriptionWhile $<...> generator expressions in the COMMAND portion of add_custom_command() are useful, I find their use is limited by the fact they cannot be used in other parts of add_custom_command(), such as OUTPUT. For example, in my project, I need a custom command to copy some files to the directory where a target's executable resides. In other words, I need the following:

add_custom_command(
 OUTPUT "$<TARGET_FILE_DIR:MyTarget>/TheExtraFile"
 COMMAND "${CMAKE_EXECUTABLE}" -E copy Path_To/TheExtraFile "$<TARGET_FILE_DIR:MyTarget>/TheExtraFile"
 VERBATIM
)

While in the COMMAND part, the generator expression is interpreted correctly, in OUTPUT it's not, and CMake produces an error: "add_custom_command called with OUTPUT containing a "<". This character is not allowed."

I saw 0009974 which would offer a superset od the above functionality, but the above would offer simpler syntax for this more specific class of uses.
TagsNo tags attached.
Attached Files

 Relationships
duplicate of 0013840closedKitware Robot Allow generator expressions anywhere 
related to 0009974closedBrad King CMake should support custom commands that can vary by configuration. 

  Notes
(0028305)
Michael Wild (reporter)
2012-01-16 04:25

Just as a temporary workaround you can use a stamp-file in your OUTPUT option which you create with "COMMAND ${CMAKE_COMMAND} -E touch stamp_file". Of course, this stamp file should be unique.
(0028307)
Petr Kmoch (reporter)
2012-01-16 05:01

Thanks for the tip. However, there is a problem with trying to generate a unique name for the stamp file in a generator with multiple configurations (Visual Studio). To make it unique, I'd somehow need to embed the name of the configuration into the filename - and that's where I need generator expressions again.

That's how I actually arrived at this problem - no way to smuggle the configuration name into OUTPUT. My current workaround is having one target per configuration (i.e. CopyFiles_Debug, CopyFiles_Release), which is far from ideal, as it clutters "Build All" etc.
(0028315)
Brad King (manager)
2012-01-16 08:52

Unfortunately this will be very difficult to implement and may need some internal redesign of CMake. We use the output file name for a bunch of things that are needed prior to the completion of the configuration step. The generator expressions cannot be evaluated until generate time which is too late.
(0032007)
Brad King (manager)
2013-01-08 16:09

Resolving as duplicate of 0013840 because that one subsumes this one.
(0033183)
Robert Maynard (manager)
2013-06-03 09:05

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2012-01-16 03:49 Petr Kmoch New Issue
2012-01-16 04:25 Michael Wild Note Added: 0028305
2012-01-16 05:01 Petr Kmoch Note Added: 0028307
2012-01-16 08:42 Brad King Relationship added related to 0009974
2012-01-16 08:52 Brad King Note Added: 0028315
2012-01-16 08:52 Brad King Status new => backlog
2013-01-08 11:30 Brad King Relationship added has duplicate 0013840
2013-01-08 16:09 Brad King Note Added: 0032007
2013-01-08 16:09 Brad King Status backlog => resolved
2013-01-08 16:09 Brad King Resolution open => duplicate
2013-01-08 16:09 Brad King Relationship replaced duplicate of 0013840
2013-06-03 09:05 Robert Maynard Note Added: 0033183
2013-06-03 09:05 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team