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

cmake

Solution

There is a special token since 2.8.11 version: $<SEMICOLON> (http://www.cmake.org/cmake/help/v2.8.11/cmake.html#command:add_custom_command).

I use it for example for such find command:

find /path/to/search -name some\*name \! -path excluded\*Pattern -exec ln -sf "{}" \;

the following way:

set(
    FIND_ARGUMENTS
    "${SEARCH_PATH} -name some\\*name \\! -path exclued\\*Pattern -exec ln -sf {} \\$<SEMICOLON>"
)

separate_arguments(FIND_ARGUMENTS)

add_custom_command(TARGET ${PROJECT}
    POST_BUILD
    COMMAND "find" ${FIND_ARGUMENTS}
    WORKING_DIRECTORY ${WORKING_PATH}
)

Note that with separate_arguments VERBATIM parameter for add_custom_command is not needed.

Problem

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?

Original source