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