[CMake] file(DOWNLOAD ...) at build time

David Cole dlrdave at aol.com
Mon Mar 11 12:12:06 EDT 2013


 

The simplest way is to make a “download only” ExternalProject, by using something like:

 

    ExternalProject_Add(proj

      DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/downloads

      URL http://...

      URL_MD5 31267132687126...

      CONFIGURE_COMMAND “”

      BUILD_COMMAND “”

      INSTALL_COMMAND “”

    )

 

 

Alternatively, you could use add_custom_command to run a CMake script at build time that does the file(DOWNLOAD.

 

    add_custom_command(COMMAND ${CMAKE_COMMAND} -P

      ${CMAKE_CURRENT_SOURCE_DIR}/download.cmake)

 

And then in download.cmake:

 

    file(DOWNLOAD .....)

 

ExternalProject does all that for you, and even extracts tarballs and moves them into the SOURCE_DIR for you, which you can see if you poke around enough underneath the hood.

 

 

HTH,

David

 


From: Luc J. Bourhis
Sent: ‎March‎ ‎11‎, ‎2013 ‎12‎:‎00‎ ‎PM
To: cmake at cmake.org
Subject: [CMake] file(DOWNLOAD ...) at build time


Is there a simple pattern to make file(DOWNLOAD ...) do the actual
downloading at build time? I tried to understand how ExternalProject_Add
does it but to no avail.




-----
--
Luc J. Bourhis

--
View this message in context: http://cmake.3232098.n2.nabble.com/file-DOWNLOAD-at-build-time-tp7583578.html
Sent from the CMake mailing list archive at Nabble.com.
--

Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130311/9d739cf8/attachment.htm>


More information about the CMake mailing list