<div dir="ltr">Not working too.<div>The failed lines in a generated make file looks like this</div><div>-----------------------</div><div>CMakeFiles/mkflags_test:<br>        /usr/bin/cmake -DDEFINITIONS=-DAPI=__attribute__((visibility("default"))) -DFILENAME=/home/ekarpov/tmp/build/flags.txt -P /home/ekarpov/tmp/escape_quotes.cmake<br></div><div>-----------------------<br></div><div><br></div><div>And I've tried to double quote the DEFINITIONS parameter that is passed to cmake - didn't help.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">пт, 30 авг. 2019 г. в 18:15, Kyle Edwards <<a href="mailto:kyle.edwards@kitware.com">kyle.edwards@kitware.com</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Fri, 2019-08-30 at 17:54 +0300, Eugene Karpov wrote:<br>
> I've tried this. But then it fails to compile due to `INTERFACE<br>
> API=${API_EXPORT_MACRO}` target compile definition.<br>
<br>
Ah right, you want the file contents to be escaped while the compile<br>
flags are not. My next suggestion was going to be to use a generator<br>
expression that replaces `"` with `\"`, but there does not appear to be<br>
a "string replace" genex. In that case, I would suggest using<br>
add_custom_command()/add_custom_target() to call a cmake -P script<br>
which escapes the quotes and writes the file. For example:<br>
<br>
set(_compile_definitions<br>
"$<TARGET_PROPERTY:${_target},COMPILE_DEFINITIONS>")<br>
set(_compile_definitions "$<$<BOOL:${_compile_definitions}>:-<br>
D$<JOIN:${_compile_definitions},\n-D>\n>")<br>
add_custom_target(mkflags_${_target} COMMAND ${CMAKE_COMMAND} "-<br>
DDEFINITIONS=${_compile_definitions}" "-DFILENAME=${_filename}" -P<br>
path/to/script.cmake BYPRODUCTS "${_filename}")<br>
<br>
And then the script would look like:<br>
<br>
string(REPLACE "\"" "\\\"" DEFINITIONS "${DEFINITIONS}")<br>
file(WRITE "${FILENAME}" "${DEFINITIONS}")<br>
<br>
Kyle<br>
</blockquote></div>