<div dir="ltr"><div>No idea on this one. The trick I showed is "vanilla CMake," a direct consequence of the CMake parsing & string processing algorithm. What you're asking is about the internals of ExternalProject_Add, of which I know nothing.<br><br></div>Petr<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 21, 2015 at 1:43 PM, Cedric Doucet <span dir="ltr"><<a href="mailto:cedric.doucet@inria.fr" target="_blank">cedric.doucet@inria.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-family:times new roman,new york,times,serif;font-size:12pt;color:#000000"><div><br></div><div>Hi Petr!</div><div><br></div><div>Thank you for the trick: it's very powerful!</div><div><br></div><div>Does this mean that these two calls are equivalent if I write: <span style="font-size:12pt;font-family:Helvetica,Arial,sans-serif">set(the_configure_command CONFIGURE_COMMAND)</span><span style="font-size:12pt">?</span></div><span class=""><div><br></div><div><div style="font-family:Helvetica,Arial,sans-serif"><div>ExternalProject_Add(${${LIBRARY}_LOWERNAME}<br>  PREFIX ${${LIBRARY}_PREFIX}</div>  URL ${${LIBRARY}_URL}</div><span style="font-family:Helvetica,Arial,sans-serif">  ${the_configure_command}</span><br style="font-family:Helvetica,Arial,sans-serif"><span style="font-family:Helvetica,Arial,sans-serif">)</span></div><div><span style="font-family:Helvetica,Arial,sans-serif"><br></span></div></span><div><span class=""><span style="font-family:Helvetica,Arial,sans-serif"><span style="font-family:Helvetica,Arial,sans-serif"></span></span><div style="font-family:Helvetica,Arial,sans-serif"><div>ExternalProject_Add(${${LIBRARY}_LOWERNAME}<br>  PREFIX ${${LIBRARY}_PREFIX}</div>  URL ${${LIBRARY}_URL}</div></span><span style="font-family:Helvetica,Arial,sans-serif"><span style="font-family:Helvetica,Arial,sans-serif">)</span><br></span></div><div><br></div><div>I guess the default value of CONFIGURE_COMMAND will be used, right?</div><div><br></div><div>Cédric</div><div><br></div><div><br></div><hr><blockquote style="border-left:2px solid #1010ff;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt"><b>De: </b>"Petr Kmoch" <<a href="mailto:petr.kmoch@gmail.com" target="_blank">petr.kmoch@gmail.com</a>><br><b>À: </b>"Cedric Doucet" <<a href="mailto:cedric.doucet@inria.fr" target="_blank">cedric.doucet@inria.fr</a>><br><b>Cc: </b><a href="mailto:cmake@cmake.org" target="_blank">cmake@cmake.org</a><br><b>Envoyé: </b>Jeudi 21 Mai 2015 13:33:27<br><b>Objet: </b>Re: [CMake] How to skip steps and use default values in ExternalProject_Add command?<div><div class="h5"><br><div><br></div><div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div>Hi Cedric.<br><div><br></div></div>When doing things like that, remember that CMake's "named arguments" are arguments just like any other. So you can easily obtain them from variable expansion; something like this:<br><div><br></div></div>if(${LIBRARY}_CONFIGURE_COMMAND)<br></div>  set(the_configure_command CONFIGURE_COMMAND ${${LIBRARY}_CONFIGURE_COMMAND})<br></div>else()<br></div>  set(the_configure_command "")<br></div>endif()<br><div><br></div></div>ExternalProject_Add(${${LIBRARY}_LOWERNAME}<br>  PREFIX ${${LIBRARY}_PREFIX}<br></div>  URL ${${LIBRARY}_URL}<br></div>  ${the_configure_command}<br>  BUILD_COMMAND ${${LIBRARY}_BUILD_COMMAND}<br>  INSTALL_COMMAND ${${LIBRARY}_INSTALL_COMMAND}<br>)<br><div><br></div></div>The same trick can be applied to any other command you need to conditionally exclude, of course.<br><div><br></div></div>Petr<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 21, 2015 at 1:10 PM, Cedric Doucet <span dir="ltr"><<a href="mailto:cedric.doucet@inria.fr" target="_blank">cedric.doucet@inria.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-family:times new roman,new york,times,serif;font-size:12pt;color:#000000"><div>Hello,</div><div><br></div><div>I would like to loop on a list of libraries to download and install, by calling the ExternalProject_Add command for each of these libraries.</div><div>To do that, I need to define some commands for each library, like CONFIGURE_COMMAND, BUILD_COMMAND and INSTALL_COMMAND.</div><div>These commands may differ from one library to another; for example, some of them may be based on make, or autoconfig, or cmake, etc.</div><div>Furthermore, some of these libraries may not need to be built.</div><div><br></div><div>What is the good way to skip some steps?</div><div><span style="font-size:12pt">Is it possible to use default values for some commands?</span></div><div><br></div><div>The problem in my situation is that I have to fill in each command since I want to design way of downloading and installing third party libraries.</div><div>To be clear, I wrote a loop which looks like this:</div><div><br></div><div>==========================================================================</div><div>foreach(LIBRARY IN LISTS NOT_FOUND_LIBRARIES)</div><div>    ExternalProject_Add(${${LIBRARY}_LOWERNAME}</div><div>                                       PREFIX ${${LIBRARY}_PREFIX}</div><div>                                       URL ${${LIBRARY}_URL}</div><div>                                       CONFIGURE_COMMAND ${${LIBRARY}_CONFIGURE_COMMAND}</div><div>                                       BUILD_COMMAND ${${LIBRARY}_BUILD_COMMAND}</div><div>                                       INSTALL_COMMAND ${${LIBRARY}_INSTALL_COMMAND}</div><div>                                     )</div><div>endforeach(LIBRARY)</div><div>==========================================================================</div><div><br></div><div>However, if a library is based on cmake, I do not need to specify commands for configuration and building.</div><div>Is it possible to say that the default value of CONFIGURE_COMMAND will be used for example?</div><div>The only way I know to do that is to suppress the line defining CONFIGURE_COMMAND but I can't do that since other libraries may need to define it.</div><div><br></div><div>To skip steps, I replace the corresponding command by 'ls' but it's not very clean.</div><div>That is to say, the value of ${LIBRARY}_CONFIGURE_COMMAND is 'ls' when I want to skip the configuration step.</div><div><br></div><div>Thank you very much for your help.</div><div><br></div><div>Cédric</div><div><br></div></div></div><br>--<br>
<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</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/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" target="_blank">http://cmake.org/cmake/help/training.html</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/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br></blockquote></div><br></div>
</div></div></blockquote><br></div></div></blockquote></div><br></div>