I wrote a cmake command like this:
add_custom_target(testar
COMMAND clearmake -C gnu ${CMD_ARGS})
the CMD_ARGS is defined on the command line like:
cmake -DCMD_ARGS="-d -w"
But in the generated makefile, the -d -w is changed into -d\ -w; it added a slash before all spaces, resulting in:
clearmake -C gnu -d\ -w
If I use VERBATIM option in add_custom_target, cmake doesn’t add a slash, but it quotes the argument like
clearmake -C gnu "-d -w"
which is incorrect, I would like:
clearmake -C gnu -d -w
What is the syntax needed to generate the above target?
The arguments are expected to be a
list, which "-d -w" is not (it’s just a string). You can do two things:CMD_ARGSbefore you pass it intoadd_custom_target(which makes spaces semi-colons to generate a properlist).Nothing in the
add_custom_targetcommand needs to change, the input to CMake is incorrect which can be fixed with 1 or handled by 2.