[CMake] more targets to run in parallel

David Cole david.cole at kitware.com
Mon Feb 20 11:21:11 EST 2012


On Mon, Feb 20, 2012 at 11:03 AM, Andrea Crotti
<andrea.crotti.0 at gmail.com>wrote:

>  On 02/20/2012 03:50 PM, David Cole wrote:
>
> On Mon, Feb 20, 2012 at 10:42 AM, Eric Noulard <eric.noulard at gmail.com>wrote:
>
>> 2012/2/20 Andrea Crotti <andrea.crotti.0 at gmail.com>:
>>  > On 02/20/2012 03:15 PM, David Cole wrote:
>> >
>> >
>> > Use:
>> >
>> >   COMMAND ls -l
>> >
>> > Not:
>> >
>> >   COMMAND "ls -l"
>> >
>> >
>> > Yes thanks, I started using the "" because I noticed that sometimes
>> they are
>> > needed.
>> > So suppose I want to split the options and the command, this:
>> >
>> > set(myoptions one two three)
>> > set(mycmd ls -l)
>> >
>> > message(${mycmd} ${myoptions})
>> >
>> > will produce
>> > ls-lonetwothree
>> >
>> > Which is not what I want, but with " I get even a more strange result:
>> > message("${mycmd} ${myoptions}")
>> >
>> > ls;-l one;two;three
>> >
>> > and in the list command I don't see any way to simply concatenate two
>> lists,
>> > so how should I merge two different lists to produce a command?
>>
>>  You may avoid to create a list in the first place:
>> set(myoptions "one two three")
>> instead of
>> set(myoptions one two three)
>>
>> see
>> cmake --help-command list
>>
>> or you can
>> string(REPLACE ";" " " stringopts "${myoptions}")
>> message(STATUS "${stringopts}")
>>
>>
>> --
>> Erk
>> Membre de l'April - « promouvoir et défendre le logiciel libre » -
>> http://www.april.org
>>
>
>
>  If you have:
>
>    set(myoptions one two three)
>   set(mycmd ls -l)
>
>  Then:
>
>    COMMAND ${mycmd} ${myoptions}
>
>  should give you what you expect. (Regardless of what the "message"
> command's output is.)
>
>
>
> Ah yes you're probably right, I tried it and it works.
> It would still be nice to understand how to pass generated lists to
> COMMAND, but that's a plus for
> the moment, and apparently too hard to get right..
>

In add_custom_command, if you pass

  COMMAND some_command ${list_of_args}

then each element of the list ends up as a separate argument to your
command.

If you pass:

  COMMAND some_command "${list_of_args}"

then  your command gets a single argument. If the list contains more than 1
element, then your argument will have semi-colons in it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120220/f6c4d171/attachment.htm>


More information about the CMake mailing list