View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015605CMakeDocumentationpublic2015-06-07 15:522016-01-04 11:51
ReporterPeter Wu 
Assigned ToBrad King 
PrioritynormalSeveritytextReproducibilityN/A
StatusclosedResolutionfixed 
PlatformOSOS Version
Product VersionCMake 3.2.3 
Target VersionCMake 3.3Fixed in VersionCMake 3.3 
Summary0015605: Mention TARGET_FILE for COMMAND option of add_custom_command
DescriptionWhile trying to set an environment variable in an add_custom_command target, I found http://www.cmake.org/pipermail/cmake/2006-March/008522.html [^] which describes this syntax:

    add_custom_command(TARGET foo
      COMMAND ${CMAKE_COMMAND} -E env
      VAR=VAL somecommand ...)

This works when somecommand is a system command, but in my case it was an executable which was previously added by add_executable(somecommand ...).

The documentation at http://www.cmake.org/cmake/help/v3.2/command/add_custom_command.html [^] describes how this special behavior works:

    "If COMMAND specifies an executable target (created by the add_executable() command) it will automatically be replaced by the location of the executable created at build time."

While the following paragraph mentions generator expressions (thanks again Nils Gladitz!), it would help if $<TARGET_FILE:somecommand> was mentioned in the same sentence for cases like the above (cmake -E env).
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0038891)
Brad King (manager)
2015-06-08 09:08

I've added it to the docs here:

 Help: Reference TARGET_FILE genex in add_custom_command docs
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0e708d17 [^]

and scheduled for merge to 'release' for 3.3.0-rc2.
(0040061)
Robert Maynard (manager)
2016-01-04 11:51

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

 Issue History
Date Modified Username Field Change
2015-06-07 15:52 Peter Wu New Issue
2015-06-08 09:08 Brad King Note Added: 0038891
2015-06-08 09:08 Brad King Assigned To => Brad King
2015-06-08 09:08 Brad King Status new => resolved
2015-06-08 09:08 Brad King Resolution open => fixed
2015-06-08 09:08 Brad King Fixed in Version => CMake 3.3
2015-06-08 09:08 Brad King Target Version => CMake 3.3
2016-01-04 11:51 Robert Maynard Note Added: 0040061
2016-01-04 11:51 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team