Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Avoid quoting in CMake add_custom_command

Tags:

quotes

cmake

I'm trying to create a simple batcher, which runs a script over a set of files.

So, after globbed files, I've created the following custom command to execute the script:

add_custom_command(OUTPUT ${RESOURCE_GFX} COMMAND ${EXE_GFX_EXPORT} ${GFX_EXPORT_PARAMETERS} ${RESOURCE_SWF})

where EXE_GFX_EXPORT is the script program, something like C:\Program Files (x86)\Scaleform\GFx SDK 3.1\Bin\gfxexport.exe; RESOURCE_SWF is the file that the script runs on; and GFX_EXPORT_PARAMETERS are script's parameters, something in the form of -i DDS -share_images -qp.

CMake "translates" this custom command in:

"C:\Program Files (x86)\Scaleform\GFx SDK 3.1\Bin\gfxexport.exe" "-i DDS -share_images -qp" "C:\path\to\file.swf"

but gfxexport.exe can't handle parameters surrounded by double quotes. Is there a way to avoid CMake automatically puts them around GFX_EXPORT_PARAMETERS variable?

Thanks guys, Raffaele.

like image 291
TaaTT4 Avatar asked Mar 26 '12 10:03

TaaTT4


1 Answers

Try using the separate_arguments function on the parameter GFX_EXPORT_PARAMETERS before invoking add_custom_command:

separate_arguments(GFX_EXPORT_PARAMETERS_LIST WINDOWS_COMMAND "${GFX_EXPORT_PARAMETERS}")
add_custom_command(OUTPUT ${RESOURCE_GFX} COMMAND ${EXE_GFX_EXPORT} ${GFX_EXPORT_PARAMETERS_LIST} ${RESOURCE_SWF})
like image 181
sakra Avatar answered Oct 01 '22 21:10

sakra