[CMake] Passing multiple arguments to add_custom_command

Iman Brouwer iman.brouwer at gmail.com
Mon Jun 1 16:31:33 EDT 2009


Hello,

I'm trying to pass multiple arguments to a python script. The last arguments
are file names that are already in a cmake list (semicolon seperated
string).
Is it possible to pass the elements in this list to the python script as
separate arguments?

------------------
SET( sources s1.cpp s2.cpp s3.cpp )
SET( arguments "-c 2" )

#Add the source files
FOREACH( cpp ${sources } )
    SET( arguments "${arguments} ${cpp}" )
ENDFOREACH( cpp )
add_custom_command( TARGET test COMMAND "script.py" "${arguments}" )
--------------------

The above cmake script will call script.py with the "-c 2 s1.cpp s2.cpp
s3.cpp" as a single argument instead of 5 individual arguments

Manually typing them out as individual strings does solve the problem but
would be impractical:
add_custom_command( TARGET test COMMAND "script.py" "-c" "5" "s1.cpp"
"s2.cpp" )

Any help would be greatly appreciated,

Iman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090601/5c943c99/attachment.htm>


More information about the CMake mailing list