I am trying to run sed
from CMake. The problem is that CMake really messes up the expressions passed to sed
. Here's a snippet from the CMakeLists.txt
file:
${SED_TOOL} -e "'1 s@.*@\#include \"config.hpp\"\\nnamespace LANG_NAMESPACE {\\nnamespace lexyacc {\\n\\n&@'" -e "'\$ s@.*@&\\n}}\\n@'"
And here's what CMake turns it into:
/bin/sed -e '1\ s@.*@#include\ "config.hpp"\nnamespace\ LANG_NAMESPACE\ {\nnamespace\ lexyacc\ {\n\n&@' -e '$\ s@.*@&\n}}\n@'
How should I fix this? And is there any good reference on how CMake's quoting works?
EDIT: here's an example开发者_如何学编程:
http://pastebin.com/G9NRfrp7
http://pastebin.com/y9776Lt9
Why do you think you need the outer-most surrounding dbl-quote chars. Cmake is almost certainly passing the sed cmd to a shell, which then executes it. Putting the sed strings in dbl-quotes means some extra evaluation will be performed. Eliminate dbl-quotes, unless you need to have a variable evaluated, and then use something like
sed -e 's/xxx/yyy/;s/'"${var1}/${var2}"'/;s/www/zzz/'
I hope this helps.
精彩评论