[CMake] Unknown argument in FOREACH

Petr Kmoch petr.kmoch at gmail.com
Mon May 18 12:16:16 EDT 2015


Hi Cedric.

If you check the documentation of foreach() (
http://www.cmake.org/cmake/help/v3.2/command/foreach.html), 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:

    foreach(LIBRARY IN LISTS LIBRARIES_TO_DOWNLOAD)

or this:

    foreach(LIBRARY ${LIBRARIES_TO_DOWNLOAD})

I always prefer the former, because the latter will fail if the first item
in the list happens to be "IN".

Petr

On Mon, May 18, 2015 at 6:05 PM, Cedric Doucet <cedric.doucet at inria.fr>
wrote:

>
> Hello,
>
> I try to write a loop to donwload and install libraries whose name is
> contained in a list.
> I wrote these lines from the 45th line of my CMakeLists.txt file:
>
> ===========================================================
> set(LIBRARIES_TO_DOWNLOAD EIGEN)
>
> foreach(LIBRARY IN ${LIBRARIES_TO_DOWNLOAD})
>     string(TOLOWER ${LIBRARY} LIBRARY_NAME)
>     ExternalProject_Add(${LIBRARY_NAME}
>                         PREFIX ${LIBRARY_PREFIX}
>                         DOWNLOAD_DIR ${${LIBRARY}_DOWNLOAD_DIR}
>                         SOURCE_DIR ${${LIBRARY}_SOURCE_DIR}
>                         BINARY_DIR ${${LIBRARY}_BINARY_DIR}
>                         STAMP_DIR  ${${LIBRARY}_STAMP_DIR}
>                         INSTALL_DIR ${${LIBRARY}_INSTALL_DIR}
>                         URL ${${LIBRARY}_URL}
>                         URL_MD5 ${${LIBRARY}_URL_MD5}
>                         CMAKE_ARGS ${${LIBRARY}_ARGS}
>                         LOG_DOWNLOAD 1
>                         LOG_UPDATE 1
>                         LOG_CONFIGURE 1
>                         LOG_BUILD 1
>                         LOG_TEST 1
>                         LOG_INSTALL 1
>                        )
> endforeach(LIBRARY)
> ===========================================================
>
> However, I get the following error message:
>
>
> =========================================================================================
> CMake Error at CMakeLists.txt:45 (foreach):
>   Unknown argument:
>     EIGEN
>
> CMake Error at CMakeLists.txt:46 (string):
>   string no output variable specified
>
> CMake Error at
> /usr/local/bibliotheques/cmake/3.2.2/share/cmake-3.2/Modules/ExternalProject.cmake:1850
> (message):
>   error: no download info for 'PREFIX' -- please specify existing/non-empty
>   SOURCE_DIR or one of URL, CVS_REPOSITORY and CVS_MODULE, SVN_REPOSITORY,
>   GIT_REPOSITORY, HG_REPOSITORY or DOWNLOAD_COMMAND
> Call Stack (most recent call first):
>
> /usr/local/bibliotheques/cmake/3.2.2/share/cmake-3.2/Modules/ExternalProject.cmake:2321
> (_ep_add_download_command)
>   CMakeLists.txt:47 (ExternalProject_Add)
>
> CMake Error at CMakeLists.txt:64 (endforeach):
>   endforeach An ENDFOREACH command was found outside of a proper FOREACH
>   ENDFOREACH structure.  Or its arguments did not match the opening FOREACH
>   command.
>
> =========================================================================================
>
> Do you know where the problem come from?
>
> Cheers,
>
> Cédric
>
>
>
>
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150518/e16036c0/attachment.html>


More information about the CMake mailing list