target-compile-options() always escapes strings.
It is currently (as of da0a7d28) impossible to pass certain characters to the compiler as they are always escaped. For example adding /wd"1234"
is not possible as the quotes get escaped. It works with setting the flags globally but not when using target_compile_options()
.
It seems they are always parsed by AppendFlagEscape()
in cmLocalGenerator.cxx
. Also using bracket arguments [=[/wd"1234"]=]
is of no use. The brackets are removed by cmake before AppendFlagEscape()
is called (even if they weren't they aren't recognised by it anyways).
Example:
target_compile_options("foo" PRIVATE
/wd"1234"
`pkg-config --cflags xyz`
[=[/wd"1234"]=]
[=[`pkg-config --cflags xyz`]=]
)
Result:
CXX_FLAGS = /wd\"1234\" "\`pkg-config" --cflags "xyz\`" "\`pkg-config --cflags xyz\`"