String escaping with target_compile_options()

I need to pass some unorthodox arguments to the compiler, but without having their special characters escaped, like /wd"1234". This works with setting the flags variable globally but not when using target_compile_options(). It always escapes the special characters. Is there a way to disable this for some values? I took a peek into the cmake source code but it wasn’t obvious to me. Things I tried:

target_compile_options("my_awesome_target" PRIVATE
  `echo 1234`
  $(echo 1234)
  "`echo 1234`"
  "$(echo 1234)"
  "\`echo 1234\`"

I know the immediate problems these arguments solve can be solved in another way using cmake but the cmake is auto-generated itself so I have limited control over the options passed.


What you can do is use CMake string literals so that zero escaping or expansion occurs:

target_compile_options(my_awesome_target PRIVATE
  [=['echo 1234']=]

This will make sure the compiler is given /wd"1234" and 'echo 1234'

Thank your very much, I didn’t find that before.
Unfortunately it still escapes the quotes.
My guess is it always is added to the internal COMPILE_OPTIONS as entered but is escaped when the makefile is generated