summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-06-29 12:23:14 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-06-29 12:23:20 (GMT)
commite23428c99f146699dbcc724c45837cd61bc13ae7 (patch)
tree89ed0c611cb084482526a7e9fb181bce1ffadb80
parent4c28bf2acacec2de4db1465d330a410d771134d5 (diff)
parent95159b7dea20c65e3c1d9b112cd4c5f4646b6a97 (diff)
downloadCMake-e23428c99f146699dbcc724c45837cd61bc13ae7.zip
CMake-e23428c99f146699dbcc724c45837cd61bc13ae7.tar.gz
CMake-e23428c99f146699dbcc724c45837cd61bc13ae7.tar.bz2
Merge topic 'file-ARCHIVE_CREATE-rename-TYPE-option' into release-3.18
95159b7dea file(ARCHIVE_CREATE): Rename TYPE option to COMPRESSION bc45bdc819 Help: Fix contents indenting for file(ARCHIVE_...) subcommands Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4948
-rw-r--r--Help/command/file.rst32
-rw-r--r--Source/cmFileCommand.cxx18
-rw-r--r--Tests/RunCMake/File_Archive/7zip-with-bad-compression-result.txt (renamed from Tests/RunCMake/File_Archive/zip-with-bad-type-result.txt)0
-rw-r--r--Tests/RunCMake/File_Archive/7zip-with-bad-compression-stderr.txt5
-rw-r--r--Tests/RunCMake/File_Archive/7zip-with-bad-compression.cmake6
-rw-r--r--Tests/RunCMake/File_Archive/7zip.cmake2
-rw-r--r--Tests/RunCMake/File_Archive/RunCMakeTest.cmake3
-rw-r--r--Tests/RunCMake/File_Archive/gnutar-gz.cmake2
-rw-r--r--Tests/RunCMake/File_Archive/gnutar.cmake2
-rw-r--r--Tests/RunCMake/File_Archive/pax-xz.cmake2
-rw-r--r--Tests/RunCMake/File_Archive/pax-zstd.cmake2
-rw-r--r--Tests/RunCMake/File_Archive/pax.cmake2
-rw-r--r--Tests/RunCMake/File_Archive/paxr-bz2.cmake2
-rw-r--r--Tests/RunCMake/File_Archive/paxr.cmake2
-rw-r--r--Tests/RunCMake/File_Archive/roundtrip.cmake6
-rw-r--r--Tests/RunCMake/File_Archive/unsupported-format.cmake2
-rw-r--r--Tests/RunCMake/File_Archive/zip-filtered.cmake2
-rw-r--r--Tests/RunCMake/File_Archive/zip-with-bad-compression-result.txt1
-rw-r--r--Tests/RunCMake/File_Archive/zip-with-bad-compression-stderr.txt (renamed from Tests/RunCMake/File_Archive/zip-with-bad-type-stderr.txt)4
-rw-r--r--Tests/RunCMake/File_Archive/zip-with-bad-compression.cmake (renamed from Tests/RunCMake/File_Archive/zip-with-bad-type.cmake)2
-rw-r--r--Tests/RunCMake/File_Archive/zip.cmake2
21 files changed, 57 insertions, 42 deletions
diff --git a/Help/command/file.rst b/Help/command/file.rst
index bb560a9..b109f9d 100644
--- a/Help/command/file.rst
+++ b/Help/command/file.rst
@@ -42,9 +42,9 @@ Synopsis
`Locking`_
file(`LOCK`_ <path> [...])
- `Archiving`_
- file(`ARCHIVE_CREATE`_ OUTPUT <archive> FILES <files> [...])
- file(`ARCHIVE_EXTRACT`_ INPUT <archive> DESTINATION <dir> [...])
+ `Archiving`_
+ file(`ARCHIVE_CREATE`_ OUTPUT <archive> FILES <files> [...])
+ file(`ARCHIVE_EXTRACT`_ INPUT <archive> DESTINATION <dir> [...])
Reading
^^^^^^^
@@ -903,28 +903,30 @@ Archiving
[FILES <files>]
[DIRECTORY <dirs>]
[FORMAT <format>]
- [TYPE <type>]
+ [COMPRESSION <compression>]
[MTIME <mtime>]
[VERBOSE])
-Creates an archive specifed by ``OUTPUT`` with the content of ``FILES`` and
-``DIRECTORY``.
+Creates the specified ``<archive>`` file with the content of ``<files>`` and
+``<dirs>``.
-To specify the format of the archive set the ``FORMAT`` option.
-Supported formats are: ``7zip``, ``gnutar``, ``pax``, ``paxr``, ``raw``,
-(restricted pax, default), and ``zip``.
+Use the ``FORMAT`` option to specify the archive format. Supported values
+for ``<format>`` are ``7zip``, ``gnutar``, ``pax``, ``paxr``, ``raw`` and
+``zip``. If ``FORMAT`` is not given, the default format is ``paxr``.
-To specify the type of compression set the ``TYPE`` option.
-Supported compression types are: ``None``, ``BZip2``, ``GZip``, ``XZ``,
-and ``Zstd``.
+Some archive formats allow the type of compression to be specified.
+The ``7zip`` and ``zip`` archive formats already imply a specific type of
+compression. The other formats use no compression by default, but can be
+directed to do so with the ``COMPRESSION`` option. Valid values for
+``<compression>`` are ``None``, ``BZip2``, ``GZip``, ``XZ``, and ``Zstd``.
.. note::
With ``FORMAT`` set to ``raw`` only one file will be compressed with the
- compression type specified by ``TYPE``.
+ compression type specified by ``COMPRESSION``.
-With ``VERBOSE`` the command will produce verbose output.
+The ``VERBOSE`` option enables verbose output for the archive operation.
-To specify the modification time recorded in tarball entries use
+To specify the modification time recorded in tarball entries, use
the ``MTIME`` option.
.. _ARCHIVE_EXTRACT:
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 268c5d1..3eea6f3 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -2941,7 +2941,7 @@ bool HandleArchiveCreateCommand(std::vector<std::string> const& args,
{
std::string Output;
std::string Format;
- std::string Type;
+ std::string Compression;
std::string MTime;
bool Verbose = false;
std::vector<std::string> Files;
@@ -2951,7 +2951,7 @@ bool HandleArchiveCreateCommand(std::vector<std::string> const& args,
static auto const parser = cmArgumentParser<Arguments>{}
.Bind("OUTPUT"_s, &Arguments::Output)
.Bind("FORMAT"_s, &Arguments::Format)
- .Bind("TYPE"_s, &Arguments::Type)
+ .Bind("COMPRESSION"_s, &Arguments::Compression)
.Bind("MTIME"_s, &Arguments::MTime)
.Bind("VERBOSE"_s, &Arguments::Verbose)
.Bind("FILES"_s, &Arguments::Files)
@@ -2970,7 +2970,7 @@ bool HandleArchiveCreateCommand(std::vector<std::string> const& args,
}
const std::vector<std::string> LIST_ARGS = {
- "OUTPUT", "FORMAT", "TYPE", "MTIME", "FILES", "DIRECTORY",
+ "OUTPUT", "FORMAT", "COMPRESSION", "MTIME", "FILES", "DIRECTORY",
};
auto kwbegin = keywordsMissingValues.cbegin();
auto kwend = cmRemoveMatching(keywordsMissingValues, LIST_ARGS);
@@ -2994,10 +2994,10 @@ bool HandleArchiveCreateCommand(std::vector<std::string> const& args,
}
const char* zipFileFormats[] = { "7zip", "zip" };
- if (!parsedArgs.Type.empty() &&
+ if (!parsedArgs.Compression.empty() &&
cm::contains(zipFileFormats, parsedArgs.Format)) {
status.SetError(cmStrCat("archive format ", parsedArgs.Format,
- " does not support TYPE arguments"));
+ " does not support COMPRESSION arguments"));
cmSystemTools::SetFatalErrorOccured();
return false;
}
@@ -3015,12 +3015,12 @@ bool HandleArchiveCreateCommand(std::vector<std::string> const& args,
std::back_inserter(files));
cmSystemTools::cmTarCompression compress = cmSystemTools::TarCompressNone;
- auto typeIt = compressionTypeMap.find(parsedArgs.Type);
+ auto typeIt = compressionTypeMap.find(parsedArgs.Compression);
if (typeIt != compressionTypeMap.end()) {
compress = typeIt->second;
- } else if (!parsedArgs.Type.empty()) {
- status.SetError(
- cmStrCat("compression type ", parsedArgs.Type, " is not supported"));
+ } else if (!parsedArgs.Compression.empty()) {
+ status.SetError(cmStrCat("compression type ", parsedArgs.Compression,
+ " is not supported"));
cmSystemTools::SetFatalErrorOccured();
return false;
}
diff --git a/Tests/RunCMake/File_Archive/zip-with-bad-type-result.txt b/Tests/RunCMake/File_Archive/7zip-with-bad-compression-result.txt
index d00491f..d00491f 100644
--- a/Tests/RunCMake/File_Archive/zip-with-bad-type-result.txt
+++ b/Tests/RunCMake/File_Archive/7zip-with-bad-compression-result.txt
diff --git a/Tests/RunCMake/File_Archive/7zip-with-bad-compression-stderr.txt b/Tests/RunCMake/File_Archive/7zip-with-bad-compression-stderr.txt
new file mode 100644
index 0000000..f6bd1ab
--- /dev/null
+++ b/Tests/RunCMake/File_Archive/7zip-with-bad-compression-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at roundtrip.cmake:38 \(file\):
+ file archive format 7zip does not support COMPRESSION arguments
+Call Stack \(most recent call first\):
+ 7zip-with-bad-compression.cmake:6 \(include\)
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/File_Archive/7zip-with-bad-compression.cmake b/Tests/RunCMake/File_Archive/7zip-with-bad-compression.cmake
new file mode 100644
index 0000000..7461eb8
--- /dev/null
+++ b/Tests/RunCMake/File_Archive/7zip-with-bad-compression.cmake
@@ -0,0 +1,6 @@
+set(OUTPUT_NAME "test.zip")
+
+set(ARCHIVE_FORMAT 7zip)
+set(COMPRESSION_TYPE XZ)
+
+include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake)
diff --git a/Tests/RunCMake/File_Archive/7zip.cmake b/Tests/RunCMake/File_Archive/7zip.cmake
index 7b0b9b7..530e940 100644
--- a/Tests/RunCMake/File_Archive/7zip.cmake
+++ b/Tests/RunCMake/File_Archive/7zip.cmake
@@ -1,6 +1,6 @@
set(OUTPUT_NAME "test.7z")
-set(COMPRESSION_FORMAT 7zip)
+set(ARCHIVE_FORMAT 7zip)
include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake)
diff --git a/Tests/RunCMake/File_Archive/RunCMakeTest.cmake b/Tests/RunCMake/File_Archive/RunCMakeTest.cmake
index 871cb6d..2bd0cd8 100644
--- a/Tests/RunCMake/File_Archive/RunCMakeTest.cmake
+++ b/Tests/RunCMake/File_Archive/RunCMakeTest.cmake
@@ -14,4 +14,5 @@ run_cmake(zip)
run_cmake(zip-filtered)
run_cmake(unsupported-format)
-run_cmake(zip-with-bad-type)
+run_cmake(zip-with-bad-compression)
+run_cmake(7zip-with-bad-compression)
diff --git a/Tests/RunCMake/File_Archive/gnutar-gz.cmake b/Tests/RunCMake/File_Archive/gnutar-gz.cmake
index f4e3975..829022b 100644
--- a/Tests/RunCMake/File_Archive/gnutar-gz.cmake
+++ b/Tests/RunCMake/File_Archive/gnutar-gz.cmake
@@ -1,6 +1,6 @@
set(OUTPUT_NAME "test.tar.gz")
-set(COMPRESSION_FORMAT gnutar)
+set(ARCHIVE_FORMAT gnutar)
set(COMPRESSION_TYPE GZip)
include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake)
diff --git a/Tests/RunCMake/File_Archive/gnutar.cmake b/Tests/RunCMake/File_Archive/gnutar.cmake
index e5cbd35..17425c7 100644
--- a/Tests/RunCMake/File_Archive/gnutar.cmake
+++ b/Tests/RunCMake/File_Archive/gnutar.cmake
@@ -1,6 +1,6 @@
set(OUTPUT_NAME "test.tar")
-set(COMPRESSION_FORMAT gnutar)
+set(ARCHIVE_FORMAT gnutar)
include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake)
diff --git a/Tests/RunCMake/File_Archive/pax-xz.cmake b/Tests/RunCMake/File_Archive/pax-xz.cmake
index 47fb0fd..ae485fd 100644
--- a/Tests/RunCMake/File_Archive/pax-xz.cmake
+++ b/Tests/RunCMake/File_Archive/pax-xz.cmake
@@ -1,6 +1,6 @@
set(OUTPUT_NAME "test.tar.xz")
-set(COMPRESSION_FORMAT pax)
+set(ARCHIVE_FORMAT pax)
set(COMPRESSION_TYPE XZ)
include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake)
diff --git a/Tests/RunCMake/File_Archive/pax-zstd.cmake b/Tests/RunCMake/File_Archive/pax-zstd.cmake
index 59e0443..ba3036e 100644
--- a/Tests/RunCMake/File_Archive/pax-zstd.cmake
+++ b/Tests/RunCMake/File_Archive/pax-zstd.cmake
@@ -1,6 +1,6 @@
set(OUTPUT_NAME "test.tar.zstd")
-set(COMPRESSION_FORMAT pax)
+set(ARCHIVE_FORMAT pax)
set(COMPRESSION_TYPE Zstd)
include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake)
diff --git a/Tests/RunCMake/File_Archive/pax.cmake b/Tests/RunCMake/File_Archive/pax.cmake
index e50c74f..46002fb 100644
--- a/Tests/RunCMake/File_Archive/pax.cmake
+++ b/Tests/RunCMake/File_Archive/pax.cmake
@@ -1,6 +1,6 @@
set(OUTPUT_NAME "test.tar")
-set(COMPRESSION_FORMAT pax)
+set(ARCHIVE_FORMAT pax)
include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake)
diff --git a/Tests/RunCMake/File_Archive/paxr-bz2.cmake b/Tests/RunCMake/File_Archive/paxr-bz2.cmake
index 469a131..d38f8f3 100644
--- a/Tests/RunCMake/File_Archive/paxr-bz2.cmake
+++ b/Tests/RunCMake/File_Archive/paxr-bz2.cmake
@@ -1,6 +1,6 @@
set(OUTPUT_NAME "test.tar.bz2")
-set(COMPRESSION_FORMAT paxr)
+set(ARCHIVE_FORMAT paxr)
set(COMPRESSION_TYPE BZip2)
include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake)
diff --git a/Tests/RunCMake/File_Archive/paxr.cmake b/Tests/RunCMake/File_Archive/paxr.cmake
index e3a4d5c..ce44f05 100644
--- a/Tests/RunCMake/File_Archive/paxr.cmake
+++ b/Tests/RunCMake/File_Archive/paxr.cmake
@@ -1,6 +1,6 @@
set(OUTPUT_NAME "test.tar")
-set(COMPRESSION_FORMAT paxr)
+set(ARCHIVE_FORMAT paxr)
include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake)
diff --git a/Tests/RunCMake/File_Archive/roundtrip.cmake b/Tests/RunCMake/File_Archive/roundtrip.cmake
index 9050400..f1b0de5 100644
--- a/Tests/RunCMake/File_Archive/roundtrip.cmake
+++ b/Tests/RunCMake/File_Archive/roundtrip.cmake
@@ -1,4 +1,4 @@
-foreach(parameter OUTPUT_NAME COMPRESSION_FORMAT)
+foreach(parameter OUTPUT_NAME ARCHIVE_FORMAT)
if(NOT DEFINED ${parameter})
message(FATAL_ERROR "missing required parameter ${parameter}")
endif()
@@ -37,8 +37,8 @@ file(MAKE_DIRECTORY ${FULL_DECOMPRESS_DIR})
file(ARCHIVE_CREATE
OUTPUT ${FULL_OUTPUT_NAME}
- FORMAT "${COMPRESSION_FORMAT}"
- TYPE "${COMPRESSION_TYPE}"
+ FORMAT "${ARCHIVE_FORMAT}"
+ COMPRESSION "${COMPRESSION_TYPE}"
VERBOSE
DIRECTORY ${COMPRESS_DIR})
diff --git a/Tests/RunCMake/File_Archive/unsupported-format.cmake b/Tests/RunCMake/File_Archive/unsupported-format.cmake
index 61edc1b..4b41e65 100644
--- a/Tests/RunCMake/File_Archive/unsupported-format.cmake
+++ b/Tests/RunCMake/File_Archive/unsupported-format.cmake
@@ -1,5 +1,5 @@
set(OUTPUT_NAME "test.rar")
-set(COMPRESSION_FORMAT rar)
+set(ARCHIVE_FORMAT rar)
include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake)
diff --git a/Tests/RunCMake/File_Archive/zip-filtered.cmake b/Tests/RunCMake/File_Archive/zip-filtered.cmake
index 2d259bc..e6bdcce 100644
--- a/Tests/RunCMake/File_Archive/zip-filtered.cmake
+++ b/Tests/RunCMake/File_Archive/zip-filtered.cmake
@@ -1,6 +1,6 @@
set(OUTPUT_NAME "test.zip")
-set(COMPRESSION_FORMAT zip)
+set(ARCHIVE_FORMAT zip)
set(DECOMPRESSION_OPTIONS
FILES
diff --git a/Tests/RunCMake/File_Archive/zip-with-bad-compression-result.txt b/Tests/RunCMake/File_Archive/zip-with-bad-compression-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/File_Archive/zip-with-bad-compression-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/File_Archive/zip-with-bad-type-stderr.txt b/Tests/RunCMake/File_Archive/zip-with-bad-compression-stderr.txt
index fe12feb..72ad8c4 100644
--- a/Tests/RunCMake/File_Archive/zip-with-bad-type-stderr.txt
+++ b/Tests/RunCMake/File_Archive/zip-with-bad-compression-stderr.txt
@@ -1,5 +1,5 @@
CMake Error at roundtrip.cmake:38 \(file\):
- file archive format zip does not support TYPE arguments
+ file archive format zip does not support COMPRESSION arguments
Call Stack \(most recent call first\):
- zip-with-bad-type.cmake:6 \(include\)
+ zip-with-bad-compression.cmake:6 \(include\)
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/File_Archive/zip-with-bad-type.cmake b/Tests/RunCMake/File_Archive/zip-with-bad-compression.cmake
index ebb97a3..2badd5b 100644
--- a/Tests/RunCMake/File_Archive/zip-with-bad-type.cmake
+++ b/Tests/RunCMake/File_Archive/zip-with-bad-compression.cmake
@@ -1,6 +1,6 @@
set(OUTPUT_NAME "test.zip")
-set(COMPRESSION_FORMAT zip)
+set(ARCHIVE_FORMAT zip)
set(COMPRESSION_TYPE BZip2)
include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake)
diff --git a/Tests/RunCMake/File_Archive/zip.cmake b/Tests/RunCMake/File_Archive/zip.cmake
index 1b93058..09e84b0 100644
--- a/Tests/RunCMake/File_Archive/zip.cmake
+++ b/Tests/RunCMake/File_Archive/zip.cmake
@@ -1,6 +1,6 @@
set(OUTPUT_NAME "test.zip")
-set(COMPRESSION_FORMAT zip)
+set(ARCHIVE_FORMAT zip)
include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake)