Exit $ Dollar Sign in CMake

I am trying to run the post build command in CMake 3.1.1 with:

ADD_CUSTOM_COMMAND( TARGET mytarget POST_BUILD COMMAND for i in `ls *` \; do echo \$i \; done \; 

However, the variable $ i evaluates to zero, although I avoid the dollar sign. According to the magazines, the team is evaluated as follows:

 for i in `ls *` ; do echo ; done ; 

I tried without slipping off the dollar sign, but this led to the same problem. The double slash didn't work either. Now I'm puzzled ...

Can you suggest a way to run a team that uses dollar signs?

PS It was just an example. My actual command is a bit more complicated, and I don't think I can handle it without using dollar signs.

+5
source share
1 answer

You should use the double-dollar escape make-style:

 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/ cmake@cmake.org /msg11302.html

+6
source

All Articles