# Generator Expressions in add\_custom\_command COMMENT field

**URL:** https://discourse.cmake.org/t/generator-expressions-in-add-custom-command-comment-field/3865
**Category:** Code
**Created:** [August 2, 2021, 5:39pm UTC](https://discourse.cmake.org/t/generator-expressions-in-add-custom-command-comment-field/3865 "2021-08-02T17:39:42Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![scottaronbloom](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/b4bc9f/32.png) [@scottaronbloom](https://discourse.cmake.org/u/scottaronbloom)
#### Post date: [August 2, 2021, 5:39pm UTC](https://discourse.cmake.org/t/generator-expressions-in-add-custom-command-comment-field/3865/1 "2021-08-02T17:39:42Z")

</div>

Im trying to add a custom command, which is working fine except the “comment” section  
add\_custom\_command(TARGET shared\_lib POST\_BUILD  
COMMAND “${CMAKE\_COMMAND}” -E copy “$\<TARGET\_FILE:shared\_lib\>” “$\<TARGET\_FILE\_DIR:mainapp\>/styles”  
COMMENT “Adding shared lib file $\<TARGET\_FILE:shared\_lib\> to MainAppProject…\n”  
)

The comment when run is  
Adding shared lib file $^\<TARGET\_FILE:shared\_lib^\> to MainAppProject…

Where I would like to print out the actual file path being copied

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [August 2, 2021, 5:50pm UTC](https://discourse.cmake.org/t/generator-expressions-in-add-custom-command-comment-field/3865/2 "2021-08-02T17:50:53Z")

</div>

It seems that the `COMMENT` bit is not genex-expanded. Please file [an issue](https://gitlab.kitware.com/cmake/cmake/-/issues) to add this support.

---

<div class="post-metadata">

### Author: ![scottaronbloom](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/b4bc9f/32.png) [@scottaronbloom](https://discourse.cmake.org/u/scottaronbloom)
#### Post date: [August 2, 2021, 5:56pm UTC](https://discourse.cmake.org/t/generator-expressions-in-add-custom-command-comment-field/3865/3 "2021-08-02T17:56:24Z")

</div>

> [@scottaronbloom](#):
>
> Im trying to add a custom command, which is working fine except the “comment” section  
> add\_custom\_command(TARGET shared\_lib POST\_BUILD  
> COMMAND “${CMAKE\_COMMAND}” -E copy “$\<TARGET\_FILE:shared\_lib\>” “$\<TARGET\_FILE\_DIR:mainapp\>/styles”  
> COMMENT “Adding shared lib file $\<TARGET\_FILE:shared\_lib\> to MainAppProject…\n”  
> )
> 
> The comment when run is  
> Adding shared lib file $^\<TARGET\_FILE:shared\_lib^\> to MainAppProject…
> 
> Where I would like to print out the actual file path being copied

Done  
[https://gitlab.kitware.com/cmake/cmake/-/issues/22507](https://gitlab.kitware.com/cmake/cmake/-/issues/22507)
