From 4dd997da541be93b0cfacdd8483eaec8dd2a76d5 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Fri, 9 Sep 2016 23:19:39 +0300 Subject: 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. --- Source/cmFileCommand.cxx | 10 ++++++++++ Tests/RunCMake/file/DOWNLOAD-unused-argument-result.txt | 0 Tests/RunCMake/file/DOWNLOAD-unused-argument-stderr.txt | 5 +++++ Tests/RunCMake/file/DOWNLOAD-unused-argument.cmake | 5 +++++ Tests/RunCMake/file/DOWNLOAD-unused-argument.txt | 0 Tests/RunCMake/file/RunCMakeTest.cmake | 2 ++ Tests/RunCMake/file/UPLOAD-unused-argument-result.txt | 0 Tests/RunCMake/file/UPLOAD-unused-argument-stderr.txt | 5 +++++ Tests/RunCMake/file/UPLOAD-unused-argument.cmake | 5 +++++ Tests/RunCMake/file/UPLOAD-unused-argument.txt | 0 10 files changed, 32 insertions(+) create mode 100644 Tests/RunCMake/file/DOWNLOAD-unused-argument-result.txt create mode 100644 Tests/RunCMake/file/DOWNLOAD-unused-argument-stderr.txt create mode 100644 Tests/RunCMake/file/DOWNLOAD-unused-argument.cmake create mode 100644 Tests/RunCMake/file/DOWNLOAD-unused-argument.txt create mode 100644 Tests/RunCMake/file/UPLOAD-unused-argument-result.txt create mode 100644 Tests/RunCMake/file/UPLOAD-unused-argument-stderr.txt create mode 100644 Tests/RunCMake/file/UPLOAD-unused-argument.cmake create mode 100644 Tests/RunCMake/file/UPLOAD-unused-argument.txt diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 835b118..ae7a511 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2564,6 +2564,11 @@ bool cmFileCommand::HandleDownloadCommand(std::vector 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 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; diff --git a/Tests/RunCMake/file/DOWNLOAD-unused-argument-result.txt b/Tests/RunCMake/file/DOWNLOAD-unused-argument-result.txt new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/file/DOWNLOAD-unused-argument-stderr.txt b/Tests/RunCMake/file/DOWNLOAD-unused-argument-stderr.txt new file mode 100644 index 0000000..82a78c9 --- /dev/null +++ b/Tests/RunCMake/file/DOWNLOAD-unused-argument-stderr.txt @@ -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.$ diff --git a/Tests/RunCMake/file/DOWNLOAD-unused-argument.cmake b/Tests/RunCMake/file/DOWNLOAD-unused-argument.cmake new file mode 100644 index 0000000..2e3fbe1 --- /dev/null +++ b/Tests/RunCMake/file/DOWNLOAD-unused-argument.cmake @@ -0,0 +1,5 @@ +file(DOWNLOAD + "file://${CMAKE_CURRENT_SOURCE_DIR}/DOWNLOAD-unused-argument.txt" + "${CMAKE_CURRENT_BINARY_DIR}/unused-argument.txt" + JUNK + ) diff --git a/Tests/RunCMake/file/DOWNLOAD-unused-argument.txt b/Tests/RunCMake/file/DOWNLOAD-unused-argument.txt new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake index 5f85bba..4c05f24 100644 --- a/Tests/RunCMake/file/RunCMakeTest.cmake +++ b/Tests/RunCMake/file/RunCMakeTest.cmake @@ -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) diff --git a/Tests/RunCMake/file/UPLOAD-unused-argument-result.txt b/Tests/RunCMake/file/UPLOAD-unused-argument-result.txt new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/file/UPLOAD-unused-argument-stderr.txt b/Tests/RunCMake/file/UPLOAD-unused-argument-stderr.txt new file mode 100644 index 0000000..3c1b744 --- /dev/null +++ b/Tests/RunCMake/file/UPLOAD-unused-argument-stderr.txt @@ -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.$ diff --git a/Tests/RunCMake/file/UPLOAD-unused-argument.cmake b/Tests/RunCMake/file/UPLOAD-unused-argument.cmake new file mode 100644 index 0000000..94ac9ac --- /dev/null +++ b/Tests/RunCMake/file/UPLOAD-unused-argument.cmake @@ -0,0 +1,5 @@ +file(UPLOAD + "${CMAKE_CURRENT_SOURCE_DIR}/UPLOAD-unused-argument.txt" + "file://${CMAKE_CURRENT_BINARY_DIR}/unused-argument.txt" + JUNK + ) diff --git a/Tests/RunCMake/file/UPLOAD-unused-argument.txt b/Tests/RunCMake/file/UPLOAD-unused-argument.txt new file mode 100644 index 0000000..e69de29 -- cgit v0.12