CMake: How to output semicolon (;) as command options in ADD_CUSTOM_TARGET

Viewed 5424

Suppose I have the following CMake snippet:

MACRO(ADD_CUSTOM_TARGET_COMMAND tag OUTPUT file)
     ADD_CUSTOM_TARGET(tag
        ${ARGN}
     )

     ADD_CUSTOM_TARGET(OUTPUT file
        ${ARGN}
     )
ENDMACRO()

ADD_CUSTOM_TARGET_COMMAND(tag
    OUTPUT file
    COMMAND git tag -a -m "${msg}" 1.0.0 HEAD
    VERBATIM
)

If msg contains semicolon such as "msg1;msg2", then the actual command is expanded to

git -a -m "msg1" "msg2" 1.0.0. HEAD

which leads to a syntax error.

I have tried to use \ to escape the ; but to no avail.

What should I do?

2 Answers
Related