MantisBT - CMake
View Issue Details
0013840CMakeCMakepublic2013-01-08 11:212016-06-10 14:31
raspy 
Kitware Robot 
normalfeatureN/A
closedmoved 
CMake 2.8.10.2 
 
0013840: Allow generator expressions anywhere
add_custom_command allows to use generator expressions, but only in COMMAND sections. They cannot be used in OUTPUT or DEPENDS sections. It would be useful to support them anywhere in the CMakeLists.txt, so I could use them in variables as well. Currently if I need to create a file in the same directory as output, I would go with:

GET_TARGET_PROPERTY(OUTFILE_LOCATION file.out LOCATION)
GET_FILENAME_COMPONENT(OUTFILE_LOCATION_DIR ${OUTFILE_LOCATION} PATH)
SET(ANOTHER_FILE_NAME ${OUTFILE_LOCATION_DIR}/another.file)

It would be much more useful to just write:

SET(ANOTHER_FILE_NAME $<TARGET_FILE_DIR:file.out>/another.file)

(btw. tried this in hope of delayed expansion but it failed as well on the OUTPUT line of add_custom_command)
No tags attached.
related to 0009974closed Brad King CMake should support custom commands that can vary by configuration. 
has duplicate 0012877closed  Support generator expressions in OUTPUT 
Issue History
2013-01-08 11:21raspyNew Issue
2013-01-08 11:30Brad KingRelationship addedduplicate of 0012877
2013-01-08 11:31Brad KingStatusnew => resolved
2013-01-08 11:31Brad KingResolutionopen => duplicate
2013-01-08 16:03raspyNote Added: 0032006
2013-01-08 16:03raspyStatusresolved => feedback
2013-01-08 16:03raspyResolutionduplicate => reopened
2013-01-08 16:07Brad KingStatusfeedback => backlog
2013-01-08 16:07Brad KingResolutionreopened => open
2013-01-08 16:08Brad KingRelationship addedrelated to 0009974
2013-01-08 16:09Brad KingRelationship replacedhas duplicate 0012877
2013-03-11 18:26void.pointerNote Added: 0032587
2014-12-09 16:58Stephen KellyNote Added: 0037431
2014-12-09 16:59Stephen KellyNote Edited: 0037431bug_revision_view_page.php?bugnote_id=37431#r1632
2015-05-11 03:00Mattias LindeNote Added: 0038739
2016-06-10 14:28Kitware RobotNote Added: 0042196
2016-06-10 14:28Kitware RobotStatusbacklog => resolved
2016-06-10 14:28Kitware RobotResolutionopen => moved
2016-06-10 14:28Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0032006)
raspy   
2013-01-08 16:03   
I don't really feel this is a duplicate, since issue 0012877 is about supporting generator expressions in OUTPUT only. This request is to support them anywhere. I got another use case, where I would gladly use it in target property LINK_FLAGS. I believe this request is wider than 0012877.
(0032587)
void.pointer   
2013-03-11 18:26   
Any idea if this is going to be addressed soon? I have data that I need to copy to my output directory and I generate for Visual Studio. I prefer to specify an output file & copy that way instead of using POST_BUILD simply because the operation becomes more efficient that way.
(0037431)
Stephen Kelly   
2014-12-09 16:58   
(edited on: 2014-12-09 16:59)
As of CMake 3.1 commit

 v3.1.0-rc1~752^2 (add_custom_command: Evaluate generator expressions in DEPENDS, 2014-03-07)
 http://www.cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bbffccca [^]

generator expressions can be used in DEPENDS.

What remains to be done as requested in this bug report is generator expressions in OUTPUT (0012877).

(0038739)
Mattias Linde   
2015-05-11 03:00   
The title for this issue is rather wide, but just OUTPUT remaining limits the scope.
So I'm not sure if making an addition here or opening a new bug is the right thing to do.

Anyway, since this is related, here goes:

Would be great if add_custom_command would support generator expressions in working_directory.

ADD_CUSTOM_COMMAND(TARGET foo POST_BUILD
  COMMAND echo $<TARGET_FILE:foo>
  COMMAND echo $<TARGET_FILE_DIR:foo>
  # WORKING_DIRECTORY $<TARGET_FILE_DIR:foo>
)

The snippet above was tested with 3.2.2 and when uncommenting the working_directory line, the cd command failed in the makefile.
(0042196)
Kitware Robot   
2016-06-10 14:28   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.