From 4035ef786de80d4d2fc27cd5f03c629702f54762 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 9 Jan 2015 10:33:36 -0500 Subject: [PATCH] cmake -E tar: error out on multiple compression formats --- Source/cmcmd.cxx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 91b9e94e0..27dd08b78 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -736,17 +736,27 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args) cmSystemTools::cmTarCompression compress = cmSystemTools::TarCompressNone; bool verbose = false; + int nCompress = 0; if ( flags.find_first_of('j') != flags.npos ) { compress = cmSystemTools::TarCompressBZip2; + ++nCompress; } if ( flags.find_first_of('J') != flags.npos ) { compress = cmSystemTools::TarCompressXZ; + ++nCompress; } if ( flags.find_first_of('z') != flags.npos ) { compress = cmSystemTools::TarCompressGZip; + ++nCompress; + } + if ( nCompress > 1 ) + { + cmSystemTools::Error("Can only compress a tar file one way; " + "at most one flag of z, j, or J may be used"); + return 1; } if ( flags.find_first_of('v') != flags.npos ) {