[cmake-developers] [CMake 0015605]: Mention TARGET_FILE for COMMAND option of add_custom_command

Mantis Bug Tracker mantis at public.kitware.com
Sun Jun 7 15:52:21 EDT 2015


The following issue has been SUBMITTED. 
====================================================================== 
http://www.cmake.org/Bug/view.php?id=15605 
====================================================================== 
Reported By:                Lekensteyn
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   15605
Category:                   Documentation
Reproducibility:            N/A
Severity:                   text
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2015-06-07 15:52 EDT
Last Modified:              2015-06-07 15:52 EDT
====================================================================== 
Summary:                    Mention TARGET_FILE for COMMAND option of
add_custom_command
Description: 
While 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).
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2015-06-07 15:52 Lekensteyn     New Issue                                    
======================================================================



More information about the cmake-developers mailing list