summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorCristian Adam <cristian.adam@gmail.com>2020-05-12 19:19:31 (GMT)
committerCristian Adam <cristian.adam@gmail.com>2020-05-12 20:25:29 (GMT)
commit549599bf324ac58b0b27f6ba3849806dfa65fc93 (patch)
tree50c3f4658ca601d8a013683fd7deeedea8eb7d5b /Source
parent4dc95526868d903c7f9e9505001cb5dbeec259c0 (diff)
downloadCMake-549599bf324ac58b0b27f6ba3849806dfa65fc93.zip
CMake-549599bf324ac58b0b27f6ba3849806dfa65fc93.tar.gz
CMake-549599bf324ac58b0b27f6ba3849806dfa65fc93.tar.bz2
cmake_command: Preserve arguments to INVOKE function
Fixes: #20630
Diffstat (limited to 'Source')
-rw-r--r--Source/cmCMakeCommand.cxx25
-rw-r--r--Source/cmCMakeCommand.h4
2 files changed, 21 insertions, 8 deletions
diff --git a/Source/cmCMakeCommand.cxx b/Source/cmCMakeCommand.cxx
index c11a003..da15b1a 100644
--- a/Source/cmCMakeCommand.cxx
+++ b/Source/cmCMakeCommand.cxx
@@ -4,6 +4,9 @@
#include <algorithm>
#include <cstddef>
+#include <iosfwd>
+#include <memory>
+#include <string>
#include "cmExecutionStatus.h"
#include "cmListFileCache.h"
@@ -11,7 +14,14 @@
#include "cmRange.h"
#include "cmStringAlgorithms.h"
-bool cmCMakeCommand(std::vector<std::string> const& args,
+inline std::ostream& operator<<(std::ostream& os,
+ cmListFileArgument const& arg)
+{
+ os << arg.Value;
+ return os;
+}
+
+bool cmCMakeCommand(std::vector<cmListFileArgument> const& args,
cmExecutionStatus& status)
{
if (args.empty()) {
@@ -24,7 +34,7 @@ bool cmCMakeCommand(std::vector<std::string> const& args,
bool result = false;
- if (args[0] == "INVOKE") {
+ if (args[0].Value == "INVOKE") {
if (args.size() == 1) {
status.SetError("called with incorrect number of arguments");
return false;
@@ -32,26 +42,29 @@ bool cmCMakeCommand(std::vector<std::string> const& args,
// First argument is the name of the function to call
cmListFileFunction func;
- func.Name = args[1];
+ func.Name = args[1].Value;
func.Line = context.Line;
// The rest of the arguments are passed to the function call above
func.Arguments.resize(args.size() - 1);
for (size_t i = 2; i < args.size(); ++i) {
cmListFileArgument lfarg;
+ lfarg.Delim = args[i].Delim;
lfarg.Line = context.Line;
- lfarg.Value = args[i];
+ lfarg.Value = args[i].Value;
func.Arguments.emplace_back(lfarg);
}
result = makefile.ExecuteCommand(func, status);
- } else if (args[0] == "EVAL") {
+ } else if (args[0].Value == "EVAL") {
if (args.size() < 2) {
status.SetError("called with incorrect number of arguments");
return false;
}
- auto code_iter = std::find(args.begin(), args.end(), "CODE");
+ auto code_iter = std::find_if(
+ args.begin(), args.end(),
+ [](cmListFileArgument const& arg) { return arg.Value == "CODE"; });
if (code_iter == args.end()) {
status.SetError("called without CODE argument");
return false;
diff --git a/Source/cmCMakeCommand.h b/Source/cmCMakeCommand.h
index cf9f4c3..7dbecff 100644
--- a/Source/cmCMakeCommand.h
+++ b/Source/cmCMakeCommand.h
@@ -5,16 +5,16 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include <string>
#include <vector>
class cmExecutionStatus;
+struct cmListFileArgument;
/**
* \brief Calls a scripted or build-in command
*
*/
-bool cmCMakeCommand(std::vector<std::string> const& args,
+bool cmCMakeCommand(std::vector<cmListFileArgument> const& args,
cmExecutionStatus& status);
#endif