I can't figure out the right syntax to run a shell command in a post-build step in Cmake on Linux. I can make a simple echo
work, but when I want to e.g. iterate over all files and echo
those, I'm getting an error.
The following works:
add_custom_command(TARGET ${MY_LIBRARY_NAME}
POST_BUILD
COMMAND echo Hello world!
USES_TERMINAL)
This correctly prints Hello world!
.
But now I would like to iterate over all .obj
files and print those. I thought I should do:
add_custom_command(TARGET ${MY_LIBRARY_NAME}
POST_BUILD
COMMAND for file in *.obj; do echo @file ; done
VERBATIM
USES_TERMINAL)
But that gives the following error:
/bin/sh: 1: Syntax error: end of file unexpected
I've tried all sorts of combinations with quotation marks or starting with sh
, but none of that seems to work. How can I do this correctly?