I'm trying to run a post build command in CMake 3.1.1 via:
ADD_CUSTOM_COMMAND(
TARGET mytarget
POST_BUILD
COMMAND for i in `ls *` \; do echo \$i \; done \;
However, the $i variable is evaluated to nothing although I escape the dollar sign. According to logs the command is evaluated to:
for i in `ls *` ; do echo ; done ;
I tried without escaping the dollar sign, but it led to the same problem. Double slash didn't work either. Now I'm puzzled...
Can you suggest a way to run a command that uses dollar signs?
P.S. This was just an example. My actual command is slightly more complicated and I don't think I can work it out without using dollar signs.
You should use 'make' style escape with double dollar sign:
ADD_CUSTOM_COMMAND(
TARGET mytarget
POST_BUILD
COMMAND for i in `ls *` \; do echo $$i \; done \;
)
Related links:
https://www.gnu.org/software/make/manual/html_node/Variables-in-Recipes.html
https://www.mail-archive.com/[email protected]/msg11302.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With