<div dir="ltr"><div><div><div><div><div><div>Hi Cedric.<br><br></div>If you check the documentation of foreach() (<a href="http://www.cmake.org/cmake/help/v3.2/command/foreach.html">http://www.cmake.org/cmake/help/v3.2/command/foreach.html</a>), you will see there is no "IN item item..." syntax. Either LISTS or ITEMS has to follow after IN, or IN must be omitted altogether. So either do this:<br><br></div>    foreach(LIBRARY IN LISTS LIBRARIES_TO_DOWNLOAD)<br><br></div>or this:<br><br></div>    foreach(LIBRARY ${LIBRARIES_TO_DOWNLOAD})<br><br></div>I always prefer the former, because the latter will fail if the first item in the list happens to be "IN".<br><br></div>Petr<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 18, 2015 at 6:05 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>Hello,</div><div><br></div><div>I try to write a loop to donwload and install libraries whose name is contained in a list.<br></div><div>I wrote these lines from the 45th line of my CMakeLists.txt file:<br></div><div><br></div><div>===========================================================<br></div><div>set(LIBRARIES_TO_DOWNLOAD EIGEN)</div><div><br>foreach(LIBRARY IN ${LIBRARIES_TO_DOWNLOAD})<br>    string(TOLOWER ${LIBRARY} LIBRARY_NAME)<br>    ExternalProject_Add(${LIBRARY_NAME}<br>                        PREFIX ${LIBRARY_PREFIX}<br>                        DOWNLOAD_DIR ${${LIBRARY}_DOWNLOAD_DIR}<br>                        SOURCE_DIR ${${LIBRARY}_SOURCE_DIR}<br>                        BINARY_DIR ${${LIBRARY}_BINARY_DIR}<br>                        STAMP_DIR  ${${LIBRARY}_STAMP_DIR}<br>                        INSTALL_DIR ${${LIBRARY}_INSTALL_DIR}<br>                        URL ${${LIBRARY}_URL}<br>                        URL_MD5 ${${LIBRARY}_URL_MD5}<br>                        CMAKE_ARGS ${${LIBRARY}_ARGS}<br>                        LOG_DOWNLOAD 1<br>                        LOG_UPDATE 1<br>                        LOG_CONFIGURE 1<br>                        LOG_BUILD 1<br>                        LOG_TEST 1<br>                        LOG_INSTALL 1<br>                       )<br>endforeach(LIBRARY)<br>===========================================================<br></div><div><br></div><div>However, I get the following error message:<br></div><div><br></div><div>=========================================================================================<br></div><div>CMake Error at CMakeLists.txt:45 (foreach):<br>  Unknown argument:<br>    EIGEN<br><br>CMake Error at CMakeLists.txt:46 (string):<br>  string no output variable specified<br><br>CMake Error at /usr/local/bibliotheques/cmake/3.2.2/share/cmake-3.2/Modules/ExternalProject.cmake:1850 (message):<br>  error: no download info for 'PREFIX' -- please specify existing/non-empty<br>  SOURCE_DIR or one of URL, CVS_REPOSITORY and CVS_MODULE, SVN_REPOSITORY,<br>  GIT_REPOSITORY, HG_REPOSITORY or DOWNLOAD_COMMAND<br>Call Stack (most recent call first):<br>  /usr/local/bibliotheques/cmake/3.2.2/share/cmake-3.2/Modules/ExternalProject.cmake:2321 (_ep_add_download_command)<br>  CMakeLists.txt:47 (ExternalProject_Add)<br><br>CMake Error at CMakeLists.txt:64 (endforeach):<br>  endforeach An ENDFOREACH command was found outside of a proper FOREACH<br>  ENDFOREACH structure.  Or its arguments did not match the opening FOREACH<br>  command.<br>=========================================================================================<br><br>Do you know where the problem come from?<br></div><div><br></div><div>Cheers,<br></div><div><br></div><div>Cédric<br></div><div><br></div><div><br></div><div><br></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>