cmake -E tar: error out on multiple compression formats

This commit is contained in:
Ben Boeckel 2015-01-09 10:33:36 -05:00 committed by Brad King
parent d811d238ab
commit 4035ef786d
1 changed files with 10 additions and 0 deletions

View File

@ -736,17 +736,27 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
cmSystemTools::cmTarCompression compress = cmSystemTools::cmTarCompression compress =
cmSystemTools::TarCompressNone; cmSystemTools::TarCompressNone;
bool verbose = false; bool verbose = false;
int nCompress = 0;
if ( flags.find_first_of('j') != flags.npos ) if ( flags.find_first_of('j') != flags.npos )
{ {
compress = cmSystemTools::TarCompressBZip2; compress = cmSystemTools::TarCompressBZip2;
++nCompress;
} }
if ( flags.find_first_of('J') != flags.npos ) if ( flags.find_first_of('J') != flags.npos )
{ {
compress = cmSystemTools::TarCompressXZ; compress = cmSystemTools::TarCompressXZ;
++nCompress;
} }
if ( flags.find_first_of('z') != flags.npos ) if ( flags.find_first_of('z') != flags.npos )
{ {
compress = cmSystemTools::TarCompressGZip; 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 ) if ( flags.find_first_of('v') != flags.npos )
{ {