You may find the technique described at the following link useful (also based on ExternalProject, but slightly different take on how it's used):
https://crascit.com/2015/07/25/cmake-gtest/ On Fri, Apr 29, 2016 at 1:58 AM, Chuck Atkins <chuck.atk...@kitware.com> wrote: > This looks well suited to ExternalProject. Just give it an empty > configure and build steps and then have the install step perform the copy: > > include(ExternalProject) > > if(CMAKE_SIZEOF_VOID_P EQUAL 8) > set(3rdParty_SUBDIR x64) > else() > set(3rdParty_SUBDIR x86) > endif() > > ExternalProject_Add( 3rdParty > URL > http://download.osgvisual.org/3rdParty_VS2013_v120_x86_x64_V9_small.7z > URL_MD5 c9294a16b39783cba8c4c55df182b24b > BUILD_IN_SOURCE 1 > CONFIGURE_COMMAND "" > BUILD_COMMAND "" > INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory ${3rdParty_SUBDIR}/ > ${CMAKE_INSTALL_PREFIX} > ) > > This created a "3rdParty" target that should do everything you need and > only if necessary. > > - Chuck > > On Thu, Apr 28, 2016 at 11:19 AM, Lee Butler <iraytr...@gmail.com> wrote: > >> 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. >> >> At the moment I have the code below, which feels "unclean" on so many >> levels: >> >> if (NOT EXISTS "${CMAKE_INSTALL_PREFIX}/include/zlib.h") >> if (NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/3rdParty_x86_x64") >> if (NOT EXISTS >> "${CMAKE_CURRENT_BINARY_DIR}/3rdParty_VS2013_v120_x86_x64_V9_small.7z") >> MESSAGE(STATUS "Downloading 3rdParty") >> file(DOWNLOAD >> http://download.osgvisual.org/3rdParty_VS2013_v120_x86_x64_V9_small.7z >> "${CMAKE_CURRENT_BINARY_DIR}/3rdParty_VS2013_v120_x86_x64_V9_small.7z" >> SHOW_PROGRESS) >> endif() >> >> message(STATUS "expanding 3rdParty Archive") >> execute_process( COMMAND ${CMAKE_COMMAND} -E tar xzf >> "${CMAKE_CURRENT_BINARY_DIR}/3rdParty_VS2013_v120_x86_x64_V9_small.7z" ) >> endif() >> foreach(dir bin data include lib ssl) >> file(RENAME "${CMAKE_CURRENT_BINARY_DIR}/3rdParty_x86_x64/x64/${dir}" >> "${CMAKE_INSTALL_PREFIX}/${dir}") >> endforeach(dir) >> file(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/3rdParty_x86_x64") >> endif() >> >> 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. >> -- >> >> 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 >> > > > -- > > 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 > -- Craig Scott Melbourne, Australia http://crascit.com
-- 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