Having cmake to generate list files as per source file

GCC offers an assembler option to generate list files:


I know my way around in cmake but I am pulling my hair how to get this in. My struggle is because it is per source file that I like to have the option and the output file is based on the source file name.

Note1: I am crosscompiling for renesas RL78 but that should not matter
Note2: If I run this command manually it works; the list file is generated

So to be clear I like the compile steps to be like this:

rl78-elf-gcc.exe -ID:/sources/RL78/dev_brd_F13_gcc_led_blink/…/includes/R5F10BMG -mg14 -mmul=g14 -Wstack-usage=40 -ffunction-sections -fdata-sections -nostdlib -DDEBUG -O0 -g -Wa,-adlhn=CMakeFiles\rl78_led_blink.dir\src\main.lst -MD -MT CMakeFiles/rl78_led_blink.dir/src/main.c.obj -MF CMakeFiles\rl78_led_blink.dir\src\main.c.obj.d -o CMakeFiles/rl78_led_blink.dir/src/main.c.obj -c D:/sources/RL78/dev_brd_F13_gcc_led_blink/src/main.c

AFAIK, there’s no way to add such a flag except one-by-one. You can set the source file property COMPILE_OPTIONS to contain this, but there’s no way to say “where the object file will be written” to get its directory (yet?).