file(DOWNLOAD|UPLOAD): Warn on unexpected arguments

Emit warning message on unparsed argument instead of silently ignoring it.
Can't stop with the error message because it may break old code.
This commit is contained in:
Ruslan Baratov 2016-09-09 23:19:39 +03:00
parent d5e4cdc0f8
commit 4dd997da54
10 changed files with 32 additions and 0 deletions

View File

@ -2564,6 +2564,11 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
return false;
}
hashMatchMSG = algo + " hash";
} else {
// Do not return error for compatibility reason.
std::string err = "Unexpected argument: ";
err += *i;
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, err.c_str());
}
++i;
}
@ -2812,6 +2817,11 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
statusVar = *i;
} else if (*i == "SHOW_PROGRESS") {
showProgress = true;
} else {
// Do not return error for compatibility reason.
std::string err = "Unexpected argument: ";
err += *i;
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, err.c_str());
}
++i;

View File

@ -0,0 +1,5 @@
^CMake Warning \(dev\) at DOWNLOAD-unused-argument.cmake:[0-9]+ \(file\):
Unexpected argument: JUNK
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.$

View File

@ -0,0 +1,5 @@
file(DOWNLOAD
"file://${CMAKE_CURRENT_SOURCE_DIR}/DOWNLOAD-unused-argument.txt"
"${CMAKE_CURRENT_BINARY_DIR}/unused-argument.txt"
JUNK
)

View File

@ -1,6 +1,8 @@
include(RunCMake)
run_cmake(DOWNLOAD-hash-mismatch)
run_cmake(DOWNLOAD-unused-argument)
run_cmake(UPLOAD-unused-argument)
run_cmake(INSTALL-DIRECTORY)
run_cmake(INSTALL-MESSAGE-bad)
run_cmake(FileOpenFailRead)

View File

@ -0,0 +1,5 @@
^CMake Warning \(dev\) at UPLOAD-unused-argument.cmake:[0-9]+ \(file\):
Unexpected argument: JUNK
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.$

View File

@ -0,0 +1,5 @@
file(UPLOAD
"${CMAKE_CURRENT_SOURCE_DIR}/UPLOAD-unused-argument.txt"
"file://${CMAKE_CURRENT_BINARY_DIR}/unused-argument.txt"
JUNK
)