[CMake] Why execute_process failed escape sequence \/?

Rolf Eike Beer eike at sf-mail.de
Mon Jul 2 02:41:42 EDT 2012


> Hi,
>
> I can most of shell commands in execute_process(), but cmake failed at
> following errors when I added "sed 's/^.\///g'" to execute_process():
>
> Syntax error in cmake code, when parsing string 's/^.\///g', Invalid
> escape
> sequence \/, Call Stack ...
>
> But without the escape sequence \/, the shell command could not run, how
> can
> I make the execute_process() run shell command with escape sequence \/ ?

You must escape the backslash, so it doesn't get stripped by the CMake
parser: 's/^.\\///g'

Bonus trick: you can avoid it altogether by just using a different
character as delimiter: 's,^./,,g'

Just wondering: do you want to work on some find output? Then you also
need to escape the ".".

Eike


More information about the CMake mailing list