summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-06-17 10:47:36 (GMT)
committerKitware Robot <kwrobot@kitware.com>2021-06-17 10:47:42 (GMT)
commit1aa16906e69499a48e3624842d241b957b48a1cb (patch)
tree33bfd7254668024ecc3f1718ec2d8502fafcc006
parent3cb0cb9b09a9649d0657a223275cf4268273d26a (diff)
parentc017098d4d06ba114085ba7de47b99fc0b71e8d0 (diff)
downloadCMake-1aa16906e69499a48e3624842d241b957b48a1cb.zip
CMake-1aa16906e69499a48e3624842d241b957b48a1cb.tar.gz
CMake-1aa16906e69499a48e3624842d241b957b48a1cb.tar.bz2
Merge topic 'fix-flow-control-override'
c017098d4d CMake: Allow override of unexpected non-flow-control commands Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !6232
-rw-r--r--Source/cmCommands.cxx14
-rw-r--r--Source/cmState.cxx9
-rw-r--r--Source/cmState.h2
-rw-r--r--Tests/RunCMake/Syntax/OverrideProject-result.txt1
-rw-r--r--Tests/RunCMake/Syntax/OverrideProject-stderr.txt3
-rw-r--r--Tests/RunCMake/Syntax/RunCMakeTest.cmake1
6 files changed, 22 insertions, 8 deletions
diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx
index 9e5b783..a241a3a 100644
--- a/Source/cmCommands.cxx
+++ b/Source/cmCommands.cxx
@@ -164,36 +164,36 @@ void GetScriptingCommands(cmState* state)
state->AddBuiltinCommand("string", cmStringCommand);
state->AddBuiltinCommand("unset", cmUnsetCommand);
- state->AddUnexpectedCommand(
+ state->AddUnexpectedFlowControlCommand(
"else",
"An ELSE command was found outside of a proper "
"IF ENDIF structure. Or its arguments did not match "
"the opening IF command.");
- state->AddUnexpectedCommand(
+ state->AddUnexpectedFlowControlCommand(
"elseif",
"An ELSEIF command was found outside of a proper "
"IF ENDIF structure.");
- state->AddUnexpectedCommand(
+ state->AddUnexpectedFlowControlCommand(
"endforeach",
"An ENDFOREACH command was found outside of a proper "
"FOREACH ENDFOREACH structure. Or its arguments did "
"not match the opening FOREACH command.");
- state->AddUnexpectedCommand(
+ state->AddUnexpectedFlowControlCommand(
"endfunction",
"An ENDFUNCTION command was found outside of a proper "
"FUNCTION ENDFUNCTION structure. Or its arguments did not "
"match the opening FUNCTION command.");
- state->AddUnexpectedCommand(
+ state->AddUnexpectedFlowControlCommand(
"endif",
"An ENDIF command was found outside of a proper "
"IF ENDIF structure. Or its arguments did not match "
"the opening IF command.");
- state->AddUnexpectedCommand(
+ state->AddUnexpectedFlowControlCommand(
"endmacro",
"An ENDMACRO command was found outside of a proper "
"MACRO ENDMACRO structure. Or its arguments did not "
"match the opening MACRO command.");
- state->AddUnexpectedCommand(
+ state->AddUnexpectedFlowControlCommand(
"endwhile",
"An ENDWHILE command was found outside of a proper "
"WHILE ENDWHILE structure. Or its arguments did not "
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index 0b8a64b..ce6eb31 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -481,7 +481,7 @@ void cmState::AddDisallowedCommand(std::string const& name,
void cmState::AddUnexpectedCommand(std::string const& name, const char* error)
{
- this->AddFlowControlCommand(
+ this->AddBuiltinCommand(
name,
[name, error](std::vector<cmListFileArgument> const&,
cmExecutionStatus& status) -> bool {
@@ -496,6 +496,13 @@ void cmState::AddUnexpectedCommand(std::string const& name, const char* error)
});
}
+void cmState::AddUnexpectedFlowControlCommand(std::string const& name,
+ const char* error)
+{
+ this->FlowControlCommands.insert(name);
+ this->AddUnexpectedCommand(name, error);
+}
+
bool cmState::AddScriptedCommand(std::string const& name, BT<Command> command,
cmMakefile& mf)
{
diff --git a/Source/cmState.h b/Source/cmState.h
index 4e41156..9951b9a 100644
--- a/Source/cmState.h
+++ b/Source/cmState.h
@@ -166,6 +166,8 @@ public:
void AddDisallowedCommand(std::string const& name, BuiltinCommand command,
cmPolicies::PolicyID policy, const char* message);
void AddUnexpectedCommand(std::string const& name, const char* error);
+ void AddUnexpectedFlowControlCommand(std::string const& name,
+ const char* error);
bool AddScriptedCommand(std::string const& name, BT<Command> command,
cmMakefile& mf);
void RemoveBuiltinCommand(std::string const& name);
diff --git a/Tests/RunCMake/Syntax/OverrideProject-result.txt b/Tests/RunCMake/Syntax/OverrideProject-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/Syntax/OverrideProject-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/Syntax/OverrideProject-stderr.txt b/Tests/RunCMake/Syntax/OverrideProject-stderr.txt
new file mode 100644
index 0000000..862d5c8
--- /dev/null
+++ b/Tests/RunCMake/Syntax/OverrideProject-stderr.txt
@@ -0,0 +1,3 @@
+^CMake Error at [^
+]*/Tests/RunCMake/Syntax/Override\.cmake:[0-9]+ \(message\):
+ This shouldn't happen$
diff --git a/Tests/RunCMake/Syntax/RunCMakeTest.cmake b/Tests/RunCMake/Syntax/RunCMakeTest.cmake
index 4d24657..f0c287c 100644
--- a/Tests/RunCMake/Syntax/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Syntax/RunCMakeTest.cmake
@@ -150,3 +150,4 @@ run_override(If)
run_override(Macro)
run_override(Return)
run_override(While)
+run_override(Project)