<html><head><style data-externalstyle="true">
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph {
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
}
p.MsoListParagraphCxSpFirst, li.MsoListParagraphCxSpFirst, div.MsoListParagraphCxSpFirst, p.MsoListParagraphCxSpMiddle, li.MsoListParagraphCxSpMiddle, div.MsoListParagraphCxSpMiddle, p.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, div.MsoListParagraphCxSpLast {
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
line-height:115%;
}
</style></head><body><div data-externalstyle="false" style="font-family:Calibri,'Segoe UI',Meiryo,'Microsoft YaHei UI','Microsoft JhengHei UI','Malgun Gothic','Khmer UI','Nirmala UI',Tunga,'Lao UI',Ebrima,sans-serif;font-size:16px;"><div> </div><div>The simplest way is to make a “download only” ExternalProject, by using something like:</div><div> </div><div> ExternalProject_Add(proj</div><div> DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/downloads</div><div> URL http://...</div><div> URL_MD5 31267132687126...</div><div> CONFIGURE_COMMAND “”</div><div> BUILD_COMMAND “”</div><div> INSTALL_COMMAND “”</div><div> )</div><div> </div><div> </div><div>Alternatively, you could use add_custom_command to run a CMake script at build time that does the file(DOWNLOAD.</div><div> </div><div> add_custom_command(COMMAND ${CMAKE_COMMAND} -P</div><div> ${CMAKE_CURRENT_SOURCE_DIR}/download.cmake)</div><div> </div><div>And then in download.cmake:</div><div> </div><div> file(DOWNLOAD .....)</div><div> </div><div>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.</div><div> </div><div> </div><div>HTH,</div><div>David</div><div> </div><div data-signatureblock="true"> </div>        <div style="border-top-color: rgb(225, 225, 225); border-top-width: 1px; border-top-style: solid;">                <strong>From:</strong> Luc J. Bourhis<br>                <strong>Sent:</strong> March 11, 2013 12:00 PM<br>                <strong>To:</strong> cmake@cmake.org<br>                <strong>Subject:</strong> [CMake] file(DOWNLOAD ...) at build time<br>        </div>        <div> </div>Is there a simple pattern to make file(DOWNLOAD ...) do the actual<br>downloading at build time? I tried to understand how ExternalProject_Add<br>does it but to no avail.<br><br><br><br><br>-----<br>--<br>Luc J. Bourhis<br><br>--<br>View this message in context: http://cmake.3232098.n2.nabble.com/file-DOWNLOAD-at-build-time-tp7583578.html<br>Sent from the CMake mailing list archive at Nabble.com.<br>--<br><br>Powered by www.kitware.com<br><br>Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html<br><br>Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ<br><br>Follow this link to subscribe/unsubscribe:<br>http://www.cmake.org/mailman/listinfo/cmake<br></div></body></html>