<div class="gmail_quote">On Mon, Feb 20, 2012 at 7:58 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 class="im">On 02/20/2012 11:51 AM, Eric Noulard wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
2012/2/20 Andrea Crotti<<a href="mailto:andrea.crotti.0@gmail.com" target="_blank">andrea.crotti.0@gmail.<u></u>com</a>>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 02/17/2012 03:35 PM, Andrea Crotti wrote:<br>
..<br>
<br>
I can make the question much simpler, is it possible to generate targets<br>
dynamically with CMake?<br>
</blockquote>
As far as I know you can "generate" targets at CMake-time but not at build-time.<br>
So from my point of view this "computed target" but not really "dynamic target".<br></div><div class="im">
if you want your target to trigger the command you may<br>
add the OUTPUT of the command as a dependency of the target.<br>
<br>
add_custom_target(${t}<br>
DEPENDS ${t_cmd}<br>
)<br>
<br>
<br>
</div></blockquote>
<br>
Ah thanks now I got it, I thought that the name of the custom_command was given<br>
from the OUTPUT, for some strange reason.<br>
<br>
Doing this however:<div class="im"><br>
foreach (t ${target_list})<br>
set(t_cmd ${t}.out)<br>
add_custom_command(OUTPUT ${t_cmd}<br>
COMMAND "ls ${t}"<br></div><div class="im">
)<br>
endforeach ()<br>
<br>
foreach (t ${target_list})<br>
message("analyzing target ${t}")<br>
set(t_cmd ${t}.out)<br>
add_custom_target(${t}<br></div>
DEPENDS ${t_cmd}<br>
)<br>
endforeach ()<br>
<br>
is still problematic:<br>
~/psi_diet/test_cmake $ make uno<br>
[100%] Generating uno.out<br>
/bin/sh: ls uno: command not found<br>
make[3]: *** [uno.out] Error 127<br>
<br>
<br>
<br>
So I tried an even simpler example:<br>
add_custom_command(OUTPUT simple<br>
COMMAND "ls -l"<br>
)<br>
<br>
add_custom_target(simple<br>
DEPENDS simple<br>
)<br>
<br>
<br>
and everything works apparently, but it doesn't generate the "simple" file..<br>
How do I generate an output file which is used as dependency of the "simple"<br>
target then?<div class="HOEnZb"><div class="h5"><br>
--<br>
<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/<u></u>opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/<u></u>CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/<u></u>listinfo/cmake</a><br>
</div></div></blockquote></div><br><div><br></div><div>Use:</div><div><br></div><div><span class="Apple-style-span" style="border-collapse:collapse;color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px"> COMMAND ls -l</span></div>
<div><span class="Apple-style-span" style="border-collapse:collapse;color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span class="Apple-style-span" style="border-collapse:collapse;color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">Not:</span></div>
<div><span class="Apple-style-span" style="border-collapse:collapse;color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span class="Apple-style-span" style="border-collapse:collapse;color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px"> COMMAND "ls -l"</span></div>
<div><span class="Apple-style-span" style="border-collapse:collapse;color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px"><br></span></div>