[CMake] Unknown argument in FOREACH

Cedric Doucet cedric.doucet at inria.fr
Mon May 18 12:05:30 EDT 2015


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 




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150518/5fbb7a69/attachment.html>


More information about the CMake mailing list