Support generator expressions in OUTPUT
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
While $<...>
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.