How do I pass a compiler option that contains angle brackets into CMake's add_compiler_options()?

55 Views Asked by At

I am trying to get QT's Squish Coco code coverage tool working in my CMake-based build environment without using a CMAKE_C_FLAGS_COVERAGE global variable. I'm using CMake version 3.24.2 on Windows. I have the following global compiler options that I need to pass into add_compiler_options():

--cs-on --cs-output=P:\%F.<TEST_NAME>.${HOST_NAME}.%p.%t

I have tried several permutations but I cannot get CMake to stop adding double quotes around the entire 2nd option and its value.

Attempt 1:

add_compile_options("$<$<CONFIG:COVERAGE>:--cs-on;--cs-output=P:\%F.<TEST_NAME$<ANGLE-R>.${HOST_NAME}.%p.%t>")

gives me the following in compile_commands.json:

--cs-on \"--cs-output=P:\\coverage/%F.<TEST_NAME>.ca-pc39.%p.%t\"

Attempt 2:

add_compile_options("$<$<CONFIG:COVERAGE>:--cs-on;--cs-output=\"P:\%F.<TEST_NAME$<ANGLE-R>.${HOST_NAME}.%p.%t\">")

gives me:

--cs-on \"--cs-output=\\\"P:\\coverage/%F.<TEST_NAME>.ca-pc39.%p.%t\\\"\"

Attempt 3:

If I remove both of the angle brackets from Attempt 1 above, I get:

--cs-on --cs-output=P:\\coverage/%F.TEST_NAME.ca-pc39.%p.%t

so the angle brackets are causing this, and it happens with or without the generator expression. With the quotes present, Coco appears to be ignoring the option altogether. Is there some way to prevent this?

0

There are 0 best solutions below