summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-08-08 14:06:21 (GMT)
committerKitware Robot <kwrobot@kitware.com>2023-08-08 14:06:39 (GMT)
commitc05d06c6ed92f28bc3cb4b2a90135607c69bf3c7 (patch)
tree38938407ba620520524b0fafad76af477933ee95
parent782cdb22bda3ef8596e151fa2ad2b17c261cd530 (diff)
parent88f90a72f11bfdd16da63681ba3a5c482cf07304 (diff)
downloadCMake-c05d06c6ed92f28bc3cb4b2a90135607c69bf3c7.zip
CMake-c05d06c6ed92f28bc3cb4b2a90135607c69bf3c7.tar.gz
CMake-c05d06c6ed92f28bc3cb4b2a90135607c69bf3c7.tar.bz2
Merge topic 'file-GENERATE-arg-parsing'
88f90a72f1 file(GENERATE): Restore INPUT|CONTENT parse checking Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Merge-request: !8694
-rw-r--r--Source/cmFileCommand.cxx3
-rw-r--r--Tests/RunCMake/File_Generate/OutOfOrderArgs-result.txt1
-rw-r--r--Tests/RunCMake/File_Generate/OutOfOrderArgs-stderr.txt4
-rw-r--r--Tests/RunCMake/File_Generate/OutOfOrderArgs.cmake4
-rw-r--r--Tests/RunCMake/File_Generate/RunCMakeTest.cmake1
5 files changed, 12 insertions, 1 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index f4fbf75..70f82ad 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -2606,8 +2606,9 @@ bool HandleGenerateCommand(std::vector<std::string> const& args,
return false;
}
const bool inputIsContent = arguments.ParsedKeywords[1] == "CONTENT"_s;
- if (!inputIsContent && arguments.ParsedKeywords[1] == "INPUT") {
+ if (!inputIsContent && arguments.ParsedKeywords[1] != "INPUT") {
status.SetError("Unknown argument to GENERATE subcommand.");
+ return false;
}
std::string const& input =
inputIsContent ? *arguments.Content : *arguments.Input;
diff --git a/Tests/RunCMake/File_Generate/OutOfOrderArgs-result.txt b/Tests/RunCMake/File_Generate/OutOfOrderArgs-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/OutOfOrderArgs-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/File_Generate/OutOfOrderArgs-stderr.txt b/Tests/RunCMake/File_Generate/OutOfOrderArgs-stderr.txt
new file mode 100644
index 0000000..a3f5cd5
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/OutOfOrderArgs-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at OutOfOrderArgs\.cmake:[0-9]+ \(file\):
+ file Unknown argument to GENERATE subcommand\.
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/File_Generate/OutOfOrderArgs.cmake b/Tests/RunCMake/File_Generate/OutOfOrderArgs.cmake
new file mode 100644
index 0000000..7f0578b
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/OutOfOrderArgs.cmake
@@ -0,0 +1,4 @@
+file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output.txt"
+ CONDITION 1
+ CONTENT "CONTENT argument"
+ )
diff --git a/Tests/RunCMake/File_Generate/RunCMakeTest.cmake b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake
index 5a670ae..e601991 100644
--- a/Tests/RunCMake/File_Generate/RunCMakeTest.cmake
+++ b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake
@@ -15,6 +15,7 @@ endif()
run_cmake(EmptyCondition1)
run_cmake(EmptyCondition2)
run_cmake(BadCondition)
+run_cmake(OutOfOrderArgs)
run_cmake(DebugEvaluate)
run_cmake(GenerateSource)
run_cmake(InputAndContent)