Add .zip and .tar.bz2 extraction to ExternalProject.
Add archives of these file types and add to the test cases covered in the ExternalProject test. Also add an "Example" directory in the Tests/ExternalProject directory containing the canonical simplest example of ExternalProject usage.
This commit is contained in:
parent
e6efd9ac0a
commit
2deba1b911
|
@ -246,20 +246,16 @@ endfunction(_ep_write_downloadfile_script)
|
|||
function(_ep_write_extractfile_script script_filename filename tmp directory)
|
||||
set(args "")
|
||||
|
||||
if(filename MATCHES ".tar$")
|
||||
if(filename MATCHES "(\\.bz2|\\.tar\\.gz|\\.tgz|\\.zip)$")
|
||||
set(args xfz)
|
||||
endif()
|
||||
|
||||
if(filename MATCHES "\\.tar$")
|
||||
set(args xf)
|
||||
endif()
|
||||
|
||||
if(filename MATCHES ".tgz$")
|
||||
set(args xfz)
|
||||
endif()
|
||||
|
||||
if(filename MATCHES ".tar.gz$")
|
||||
set(args xfz)
|
||||
endif()
|
||||
|
||||
if(args STREQUAL "")
|
||||
message(SEND_ERROR "error: do not know how to extract '${filename}' -- known types are .tar, .tgz and .tar.gz")
|
||||
message(SEND_ERROR "error: do not know how to extract '${filename}' -- known types are .bz2, .tar, .tar.gz, .tgz and .zip")
|
||||
return()
|
||||
endif()
|
||||
|
||||
|
@ -274,6 +270,10 @@ message(STATUS \"extracting...
|
|||
src='\${filename}'
|
||||
dst='\${directory}'\")
|
||||
|
||||
if(NOT EXISTS \"\${filename}\")
|
||||
message(FATAL_ERROR \"error: file to extract does not exist: '\${filename}'\")
|
||||
endif()
|
||||
|
||||
# Prepare a space for extracting:
|
||||
#
|
||||
set(i 1)
|
||||
|
@ -696,7 +696,7 @@ function(_ep_add_download_command name)
|
|||
if("${url}" MATCHES "^[a-z]+://")
|
||||
# TODO: Should download and extraction be different steps?
|
||||
string(REGEX MATCH "[^/]*$" fname "${url}")
|
||||
if(NOT "${fname}" MATCHES "\\.(tar|tgz|tar\\.gz)$")
|
||||
if(NOT "${fname}" MATCHES "\\.(bz2|tar|tgz|tar\\.gz|zip)$")
|
||||
message(FATAL_ERROR "Could not extract tarball filename from url:\n ${url}")
|
||||
endif()
|
||||
set(file ${download_dir}/${fname})
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
cmake_minimum_required(VERSION 2.6)
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
project(ExternalProjectTest NONE)
|
||||
|
||||
include(ExternalProject)
|
||||
|
@ -139,6 +139,56 @@ ExternalProject_Add(${proj}
|
|||
)
|
||||
|
||||
|
||||
# Local BZ2:
|
||||
#
|
||||
# (The bz2 tests are here just to verify that the bz2 decompression is executed
|
||||
# during a test suite run... The configure and build commands are set to
|
||||
# nothing to make the test quicker. To make this more complete, I should add
|
||||
# a diff between this and the TGZ source tree since that one does build...)
|
||||
#
|
||||
set(proj TutorialStep1-LocalBZ2)
|
||||
ExternalProject_Add(${proj}
|
||||
URL "${CMAKE_CURRENT_SOURCE_DIR}/Step1.tar.bz2"
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
)
|
||||
|
||||
set(proj TutorialStep1-LocalNoDirBZ2)
|
||||
ExternalProject_Add(${proj}
|
||||
URL "${CMAKE_CURRENT_SOURCE_DIR}/Step1NoDir.tar.bz2"
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
)
|
||||
|
||||
|
||||
# Local ZIP:
|
||||
#
|
||||
# (The zip tests are here just to verify that the zip decompression is executed
|
||||
# during a test suite run... The configure and build commands are set to
|
||||
# nothing to make the test quicker. To make this more complete, I should add
|
||||
# a diff between this and the TGZ source tree since that one does build...)
|
||||
#
|
||||
set(proj TutorialStep1-LocalZIP)
|
||||
ExternalProject_Add(${proj}
|
||||
URL "${CMAKE_CURRENT_SOURCE_DIR}/Step1.zip"
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
)
|
||||
|
||||
set(proj TutorialStep1-LocalNoDirZIP)
|
||||
ExternalProject_Add(${proj}
|
||||
URL "${CMAKE_CURRENT_SOURCE_DIR}/Step1NoDir.zip"
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
)
|
||||
|
||||
|
||||
# CVS-based tests:
|
||||
#
|
||||
set(do_cvs_tests 0)
|
||||
|
||||
if(CVS_EXECUTABLE)
|
||||
|
@ -215,6 +265,8 @@ if(do_cvs_tests)
|
|||
endif()
|
||||
|
||||
|
||||
# SVN-based tests:
|
||||
#
|
||||
set(do_svn_tests 0)
|
||||
|
||||
if(Subversion_SVN_EXECUTABLE)
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
# This is the canonical simplest ExternalProject example CMakeLists.txt file:
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
project(ExternalProjectExample NONE)
|
||||
include(ExternalProject)
|
||||
|
||||
ExternalProject_Add(
|
||||
cmake281
|
||||
URL http://www.cmake.org/files/v2.8/cmake-2.8.1.tar.gz
|
||||
CMAKE_ARGS -D CMAKE_INSTALL_PREFIX=<INSTALL_DIR>
|
||||
BUILD_COMMAND ""
|
||||
)
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue