Escaped double quotes

Hello,

I am using cmake to create ninja build scripts to build my embedded firmware. I have to use some special pre-processor flags (-D__UVISION_VERSION=“533”) to be able to compile the project. But if I set the preprocessor flag the resulting command line that ninja calls is the following:

[1/6] C:\PROGRA~2\Keil_v5\ARM\ARMCLANG\bin\armclang.exe -target arm-arm-none-eabi -DXMC1404_Q064x0200 -D_RTE_ -D__UVISION_VERSION=“533” -mcpu=cortex-m0 -g --target=arm-arm-none-eabi -mcpu=cortex-m0 -fno-rtti -funsigned-char -fshort-enums -fshort-wchar -gdwarf-3 -ffunction-sections -w -MD -fdata-sections -MD -MT CMakeFiles\BSP.dir\C_\Program_Files_(x86)\Sysprogs\VisualGDB\CMake\embedded\dummy.o -MF CMakeFiles\BSP.dir\C_\Program_Files_(x86)\Sysprogs\VisualGDB\CMake\embedded\dummy.o.d -o CMakeFiles\BSP.dir\C_\Program_Files_(x86)\Sysprogs\VisualGDB\CMake\embedded\dummy.o -c “C:\Program Files (x86)\Sysprogs\VisualGDB\CMake\embedded\dummy.c”

[2/6] C:\PROGRA~2\Keil_v5\ARM\ARMCLANG\bin\armclang.exe -target arm-arm-none-eabi -DXMC1404_Q064x0200 -D_RTE_ -D__UVISION_VERSION=“533” -I…\Libraries\CMSIS\Include -I…\Libraries\CMSIS\Infineon\XMC1400_series\Include -I…\Libraries\XMCLib\inc -IC:\Users\ user \AppData\Local\Arm\Packs\ARM\CMSIS\5.7.0\CMSIS\Core\Include -IC:\Users\user\AppData\Local\Arm\Packs\Infineon\XMC1000_DFP\2.11.0\Device\XMC1400_serie

As you can see it in the ninja output the double quotes of the pre-processor flag has been escaped. Looking in the generated ninja build script shows me that the build script already contains the escaped double quotes. That is not the behaviour I want. How can I prevent CMake from escaping the double quotes when I generate the ninja build scripts?

Thanks for your help.

I think you probably want this:

add_definitions(-D__UVISION_VERSION=533)

(Note: I’ve also removed the advertisement banner from the bottom of your post.)

In cases where I must have the double quotes passed along, whether for definitions, configure_file, etc. I set the variable like

set(mysrc [=[
#include "whatever.h"
]=]
)

There are some even more tricky quote-escaping/passing cases that are easily done with that special CMake Lua-like syntax.