<div class="gmail_quote">On Mon, Feb 20, 2012 at 11:03 AM, Andrea Crotti <span dir="ltr"><<a href="mailto:andrea.crotti.0@gmail.com">andrea.crotti.0@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"><div><div class="h5">
On 02/20/2012 03:50 PM, David Cole wrote:
<blockquote type="cite">
<div class="gmail_quote">On Mon, Feb 20, 2012 at 10:42 AM, Eric
Noulard <span dir="ltr"><<a href="mailto:eric.noulard@gmail.com" target="_blank">eric.noulard@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
2012/2/20 Andrea Crotti <<a href="mailto:andrea.crotti.0@gmail.com" target="_blank">andrea.crotti.0@gmail.com</a>>:<br>
<div>
<div>> On 02/20/2012 03:15 PM, David Cole
wrote:<br>
><br>
><br>
> Use:<br>
><br>
> COMMAND ls -l<br>
><br>
> Not:<br>
><br>
> COMMAND "ls -l"<br>
><br>
><br>
> Yes thanks, I started using the "" because I noticed
that sometimes they are<br>
> needed.<br>
> So suppose I want to split the options and the
command, this:<br>
><br>
> set(myoptions one two three)<br>
> set(mycmd ls -l)<br>
><br>
> message(${mycmd} ${myoptions})<br>
><br>
> will produce<br>
> ls-lonetwothree<br>
><br>
> Which is not what I want, but with " I get even a
more strange result:<br>
> message("${mycmd} ${myoptions}")<br>
><br>
> ls;-l one;two;three<br>
><br>
> and in the list command I don't see any way to simply
concatenate two lists,<br>
> so how should I merge two different lists to produce
a command?<br>
<br>
</div>
</div>
You may avoid to create a list in the first place:<br>
set(myoptions "one two three")<br>
instead of<br>
set(myoptions one two three)<br>
<br>
see<br>
cmake --help-command list<br>
<br>
or you can<br>
string(REPLACE ";" " " stringopts "${myoptions}")<br>
message(STATUS "${stringopts}")<br>
<div>
<div><br>
<br>
--<br>
Erk<br>
Membre de l'April - « promouvoir et défendre le logiciel
libre » -<br>
<a href="http://www.april.org" target="_blank">http://www.april.org</a><br>
</div>
</div>
</blockquote>
</div>
<br>
<div><br>
</div>
<div>If you have:</div>
<div><br>
</div>
<div> set(myoptions one two three)<br>
set(mycmd ls -l)<br>
</div>
<div><br>
</div>
<div>Then:</div>
<div><br>
</div>
<div> COMMAND ${mycmd} ${myoptions}</div>
<div><br>
</div>
<div>should give you what you expect. (Regardless of what the
"message" command's output is.)</div>
<div><br>
</div>
</blockquote>
<br>
<br></div></div>
Ah yes you're probably right, I tried it and it works.<br>
It would still be nice to understand how to pass generated lists to
COMMAND, but that's a plus for<br>
the moment, and apparently too hard to get right..<br>
</div>
</blockquote></div><br><div>In add_custom_command, if you pass</div><div><br></div><div> COMMAND some_command ${list_of_args}</div><div><br></div><div>then each element of the list ends up as a separate argument to your command.</div>
<div><br></div><div>If you pass:</div><div><br></div><div> COMMAND some_command "${list_of_args}"</div><div><br></div><div>then your command gets a single argument. If the list contains more than 1 element, then your argument will have semi-colons in it.</div>
<div><br></div>