Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • CMake CMake
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 4,105
    • Issues 4,105
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 13
    • Merge requests 13
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • CMakeCMake
  • CMakeCMake
  • Issues
  • #12877
Closed
Open
Issue created Jan 15, 2012 by Kitware Robot@kwrobotOwner

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.
Edited Oct 16, 2020 by Brad King
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking