<div dir="ltr">You may find the technique described at the following link useful (also based on ExternalProject, but slightly different take on how it's used):<div><br></div><div><a href="https://crascit.com/2015/07/25/cmake-gtest/">https://crascit.com/2015/07/25/cmake-gtest/</a><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 29, 2016 at 1:58 AM, Chuck Atkins <span dir="ltr"><<a href="mailto:chuck.atkins@kitware.com" target="_blank">chuck.atkins@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>This looks well suited to ExternalProject.  Just give it an empty configure and build steps and then have the install step perform the copy:<br><br><span style="font-family:monospace,monospace">include(ExternalProject)<br><br>if(CMAKE_SIZEOF_VOID_P EQUAL 8)<br>  set(3rdParty_SUBDIR x64)<br>else()<br>  set(3rdParty_SUBDIR x86)<br>endif()<br><br>ExternalProject_Add( 3rdParty<br>  URL <a href="http://download.osgvisual.org/3rdParty_VS2013_v120_x86_x64_V9_small.7z" target="_blank">http://download.osgvisual.org/3rdParty_VS2013_v120_x86_x64_V9_small.7z</a><br>  URL_MD5 c9294a16b39783cba8c4c55df182b24b<br>  BUILD_IN_SOURCE 1<br>  CONFIGURE_COMMAND ""<br>  BUILD_COMMAND ""<br>  INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory ${3rdParty_SUBDIR}/ ${CMAKE_INSTALL_PREFIX}<br>) </span><br><br></div>This created a "3rdParty" target that should do everything you need and only if necessary.<span class="HOEnZb"><font color="#888888"><br></font></span></div><div class="gmail_extra"><span class="HOEnZb"><font color="#888888"><br clear="all"><div><div><div dir="ltr">- Chuck<br></div></div></div></font></span><div><div class="h5">
<br><div class="gmail_quote">On Thu, Apr 28, 2016 at 11:19 AM, Lee Butler <span dir="ltr"><<a href="mailto:iraytrace@gmail.com" target="_blank">iraytrace@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I am looking for a better way to do something than having a sequence of "if (NOT EXISTS)" statements.  My package being built depends on some external libraries and headers, that are available in a zip file on an external website.  So for example:  zlib.h,zlib.dll and zlib.lib are (along with other stuff) in 3rdParty.zip available from a remote URL.  I don't want to build these things, I want to fetch the zip file, unpack it and copy the relevant portions into place only as needed.<br>
<br>
At the moment I have the code below, which feels "unclean" on so many levels:<br>
<br>
if (NOT EXISTS "${CMAKE_INSTALL_PREFIX}/include/zlib.h")<br>
  if (NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/3rdParty_x86_x64")<br>
    if (NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/3rdParty_VS2013_v120_x86_x64_V9_small.7z")<br>
       MESSAGE(STATUS "Downloading 3rdParty")<br>
       file(DOWNLOAD<br>
<a href="http://download.osgvisual.org/3rdParty_VS2013_v120_x86_x64_V9_small.7z" rel="noreferrer" target="_blank">http://download.osgvisual.org/3rdParty_VS2013_v120_x86_x64_V9_small.7z</a><br>
"${CMAKE_CURRENT_BINARY_DIR}/3rdParty_VS2013_v120_x86_x64_V9_small.7z" SHOW_PROGRESS)<br>
    endif()<br>
<br>
    message(STATUS "expanding 3rdParty Archive")<br>
    execute_process( COMMAND ${CMAKE_COMMAND} -E tar xzf "${CMAKE_CURRENT_BINARY_DIR}/3rdParty_VS2013_v120_x86_x64_V9_small.7z" )<br>
  endif()<br>
  foreach(dir bin data include lib ssl)<br>
    file(RENAME "${CMAKE_CURRENT_BINARY_DIR}/3rdParty_x86_x64/x64/${dir}" "${CMAKE_INSTALL_PREFIX}/${dir}")<br>
  endforeach(dir)<br>
  file(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/3rdParty_x86_x64")<br>
endif()<br>
<br>
This has the property of fetching the 7z file, extracting the contents and leaving the 7z file around for later rebuilds.  I hope there is a cleaner way of saying the same thing.  BTW, I would be just as happy putting "products" from the zip file in the current build destinations instead of the install destinations.<br>
-- <br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" 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" rel="noreferrer" 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" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" 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" rel="noreferrer" 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" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br>
</blockquote></div><br></div></div></div>
<br>--<br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" 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" rel="noreferrer" 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" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" 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" rel="noreferrer" 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" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr">Craig Scott<br><div>Melbourne, Australia</div><div><a href="http://crascit.com" target="_blank">http://crascit.com</a><br></div></div></div></div></div>
</div>