Commit 7c47fd8c authored by Bartosz Kosiorek's avatar Bartosz Kosiorek
Browse files

cmake: tar: Display warning when no files provided during archive creation

parent b06f8c93
......@@ -1114,6 +1114,10 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
return 1;
}
} else if (flags.find_first_of('c') != std::string::npos) {
if (files.empty()) {
cmSystemTools::Message("tar: No files or directories specified",
"Warning");
}
if (!cmSystemTools::CreateTar(outFile.c_str(), files, compress,
verbose, mtime, format)) {
cmSystemTools::Error("Problem creating tar: " + outFile);
......
......@@ -4,6 +4,7 @@ function(external_command_test NAME)
run_cmake_command(${NAME} ${CMAKE_COMMAND} -E ${ARGN})
endfunction()
external_command_test(without-files tar cvf bad.tar)
external_command_test(bad-opt1 tar cvf bad.tar --bad)
external_command_test(bad-mtime1 tar cvf bad.tar --mtime=bad .)
external_command_test(bad-from1 tar cvf bad.tar --files-from=bad)
......@@ -13,10 +14,10 @@ external_command_test(bad-from4 tar cvf bad.tar --files-from=${CMAKE_CURRENT_LI
external_command_test(bad-from5 tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/bad-from5.txt)
external_command_test(end-opt1 tar cvf bad.tar -- --bad)
external_command_test(end-opt2 tar cvf bad.tar --)
external_command_test(mtime tar cvf bad.tar "--mtime=1970-01-01 00:00:00 UTC")
external_command_test(bad-format tar cvf bad.tar "--format=bad-format")
external_command_test(zip-bz2 tar cvjf bad.tar "--format=zip")
external_command_test(7zip-gz tar cvzf bad.tar "--format=7zip")
external_command_test(mtime tar cvf bad.tar "--mtime=1970-01-01 00:00:00 UTC" .)
external_command_test(bad-format tar cvf bad.tar "--format=bad-format" .)
external_command_test(zip-bz2 tar cvjf bad.tar "--format=zip" .)
external_command_test(7zip-gz tar cvzf bad.tar "--format=7zip" .)
run_cmake(7zip)
run_cmake(gnutar)
......
^tar: No files or directories specified
^tar: No files or directories specified
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment