View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0013840CMakeCMakepublic2013-01-08 11:212016-06-10 14:31
Reporterraspy 
Assigned ToKitware Robot 
PrioritynormalSeverityfeatureReproducibilityN/A
StatusclosedResolutionmoved 
PlatformOSOS Version
Product VersionCMake 2.8.10.2 
Target VersionFixed in Version 
Summary0013840: Allow generator expressions anywhere
Descriptionadd_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)
TagsNo tags attached.
Attached Files

 Relationships
related to 0009974closedBrad King CMake should support custom commands that can vary by configuration. 
has duplicate 0012877closed Support generator expressions in OUTPUT 

  Notes
(0032006)
raspy (reporter)
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 (reporter)
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 (developer)
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 (reporter)
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 (administrator)
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.

 Issue History
Date Modified Username Field Change
2013-01-08 11:21 raspy New Issue
2013-01-08 11:30 Brad King Relationship added duplicate of 0012877
2013-01-08 11:31 Brad King Status new => resolved
2013-01-08 11:31 Brad King Resolution open => duplicate
2013-01-08 16:03 raspy Note Added: 0032006
2013-01-08 16:03 raspy Status resolved => feedback
2013-01-08 16:03 raspy Resolution duplicate => reopened
2013-01-08 16:07 Brad King Status feedback => backlog
2013-01-08 16:07 Brad King Resolution reopened => open
2013-01-08 16:08 Brad King Relationship added related to 0009974
2013-01-08 16:09 Brad King Relationship replaced has duplicate 0012877
2013-03-11 18:26 void.pointer Note Added: 0032587
2014-12-09 16:58 Stephen Kelly Note Added: 0037431
2014-12-09 16:59 Stephen Kelly Note Edited: 0037431
2015-05-11 03:00 Mattias Linde Note Added: 0038739
2016-06-10 14:28 Kitware Robot Note Added: 0042196
2016-06-10 14:28 Kitware Robot Status backlog => resolved
2016-06-10 14:28 Kitware Robot Resolution open => moved
2016-06-10 14:28 Kitware Robot Assigned To => Kitware Robot
2016-06-10 14:31 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team