From 1afbe7d2cca61ecf483f7697b0141a233508603d Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Sun, 27 Nov 2016 20:38:57 +0100 Subject: Make error message of standalone endwhile command consistent with the error messages of endforeach, endmacro, endfunction, etc. --- Source/cmEndWhileCommand.cxx | 17 +++++------------ Tests/RunCMake/while/EndAlone-stderr.txt | 2 +- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/Source/cmEndWhileCommand.cxx b/Source/cmEndWhileCommand.cxx index 5623f33..7201569 100644 --- a/Source/cmEndWhileCommand.cxx +++ b/Source/cmEndWhileCommand.cxx @@ -2,21 +2,14 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmEndWhileCommand.h" -#include "cmListFileCache.h" - class cmExecutionStatus; +struct cmListFileArgument; bool cmEndWhileCommand::InvokeInitialPass( - std::vector const& args, cmExecutionStatus&) + std::vector const&, cmExecutionStatus&) { - if (args.empty()) { - this->SetError("An ENDWHILE command was found outside of a proper " - "WHILE ENDWHILE structure."); - } else { - this->SetError("An ENDWHILE command was found outside of a proper " - "WHILE ENDWHILE structure. Or its arguments did not " - "match the opening WHILE command."); - } - + this->SetError("An ENDWHILE command was found outside of a proper " + "WHILE ENDWHILE structure. Or its arguments did not " + "match the opening WHILE command."); return false; } diff --git a/Tests/RunCMake/while/EndAlone-stderr.txt b/Tests/RunCMake/while/EndAlone-stderr.txt index cd98687..5fe6655 100644 --- a/Tests/RunCMake/while/EndAlone-stderr.txt +++ b/Tests/RunCMake/while/EndAlone-stderr.txt @@ -1,5 +1,5 @@ ^CMake Error at EndAlone.cmake:1 \(endwhile\): endwhile An ENDWHILE command was found outside of a proper WHILE ENDWHILE - structure. + structure. Or its arguments did not match the opening WHILE command. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\)$ -- cgit v0.12 From d23a0196844f066047aa6942b69c6e591462df38 Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Sun, 27 Nov 2016 20:38:57 +0100 Subject: Set the error after argument expansion in end commands The current code is optimized for rare error cases. Simplify the code and remove these optimizations. --- Source/cmEndForEachCommand.cxx | 5 ++--- Source/cmEndForEachCommand.h | 13 +------------ Source/cmEndFunctionCommand.cxx | 5 ++--- Source/cmEndFunctionCommand.h | 13 +------------ Source/cmEndMacroCommand.cxx | 5 ++--- Source/cmEndMacroCommand.h | 13 +------------ Source/cmEndWhileCommand.cxx | 5 ++--- Source/cmEndWhileCommand.h | 13 +------------ 8 files changed, 12 insertions(+), 60 deletions(-) diff --git a/Source/cmEndForEachCommand.cxx b/Source/cmEndForEachCommand.cxx index fe6a7f3..81a37c3 100644 --- a/Source/cmEndForEachCommand.cxx +++ b/Source/cmEndForEachCommand.cxx @@ -3,10 +3,9 @@ #include "cmEndForEachCommand.h" class cmExecutionStatus; -struct cmListFileArgument; -bool cmEndForEachCommand::InvokeInitialPass( - std::vector const&, cmExecutionStatus&) +bool cmEndForEachCommand::InitialPass(std::vector const&, + cmExecutionStatus&) { this->SetError("An ENDFOREACH command was found outside of a proper " "FOREACH ENDFOREACH structure. Or its arguments did " diff --git a/Source/cmEndForEachCommand.h b/Source/cmEndForEachCommand.h index 772a139..e480e72 100644 --- a/Source/cmEndForEachCommand.h +++ b/Source/cmEndForEachCommand.h @@ -10,7 +10,6 @@ #include "cmCommand.h" class cmExecutionStatus; -struct cmListFileArgument; /** \class cmEndForEachCommand * \brief ends an if block @@ -26,21 +25,11 @@ public: cmCommand* Clone() CM_OVERRIDE { return new cmEndForEachCommand; } /** - * Override cmCommand::InvokeInitialPass to get arguments before - * expansion. - */ - bool InvokeInitialPass(std::vector const&, - cmExecutionStatus&) CM_OVERRIDE; - - /** * This is called when the command is first encountered in * the CMakeLists.txt file. */ bool InitialPass(std::vector const&, - cmExecutionStatus&) CM_OVERRIDE - { - return false; - } + cmExecutionStatus&) CM_OVERRIDE; /** * This determines if the command is invoked when in script mode. diff --git a/Source/cmEndFunctionCommand.cxx b/Source/cmEndFunctionCommand.cxx index 6adb42b..2d6b192 100644 --- a/Source/cmEndFunctionCommand.cxx +++ b/Source/cmEndFunctionCommand.cxx @@ -3,10 +3,9 @@ #include "cmEndFunctionCommand.h" class cmExecutionStatus; -struct cmListFileArgument; -bool cmEndFunctionCommand::InvokeInitialPass( - std::vector const&, cmExecutionStatus&) +bool cmEndFunctionCommand::InitialPass(std::vector const&, + cmExecutionStatus&) { this->SetError("An ENDFUNCTION command was found outside of a proper " "FUNCTION ENDFUNCTION structure. Or its arguments did not " diff --git a/Source/cmEndFunctionCommand.h b/Source/cmEndFunctionCommand.h index 2599637..b3cf8e6 100644 --- a/Source/cmEndFunctionCommand.h +++ b/Source/cmEndFunctionCommand.h @@ -10,7 +10,6 @@ #include "cmCommand.h" class cmExecutionStatus; -struct cmListFileArgument; /** \class cmEndFunctionCommand * \brief ends an if block @@ -26,21 +25,11 @@ public: cmCommand* Clone() CM_OVERRIDE { return new cmEndFunctionCommand; } /** - * Override cmCommand::InvokeInitialPass to get arguments before - * expansion. - */ - bool InvokeInitialPass(std::vector const&, - cmExecutionStatus&) CM_OVERRIDE; - - /** * This is called when the command is first encountered in * the CMakeLists.txt file. */ bool InitialPass(std::vector const&, - cmExecutionStatus&) CM_OVERRIDE - { - return false; - } + cmExecutionStatus&) CM_OVERRIDE; /** * This determines if the command is invoked when in script mode. diff --git a/Source/cmEndMacroCommand.cxx b/Source/cmEndMacroCommand.cxx index 046b0af..6429d7c 100644 --- a/Source/cmEndMacroCommand.cxx +++ b/Source/cmEndMacroCommand.cxx @@ -3,10 +3,9 @@ #include "cmEndMacroCommand.h" class cmExecutionStatus; -struct cmListFileArgument; -bool cmEndMacroCommand::InvokeInitialPass( - std::vector const&, cmExecutionStatus&) +bool cmEndMacroCommand::InitialPass(std::vector const&, + cmExecutionStatus&) { this->SetError("An ENDMACRO command was found outside of a proper " "MACRO ENDMACRO structure. Or its arguments did not " diff --git a/Source/cmEndMacroCommand.h b/Source/cmEndMacroCommand.h index 3c462d4..bd7cdbd 100644 --- a/Source/cmEndMacroCommand.h +++ b/Source/cmEndMacroCommand.h @@ -10,7 +10,6 @@ #include "cmCommand.h" class cmExecutionStatus; -struct cmListFileArgument; /** \class cmEndMacroCommand * \brief ends an if block @@ -26,21 +25,11 @@ public: cmCommand* Clone() CM_OVERRIDE { return new cmEndMacroCommand; } /** - * Override cmCommand::InvokeInitialPass to get arguments before - * expansion. - */ - bool InvokeInitialPass(std::vector const&, - cmExecutionStatus&) CM_OVERRIDE; - - /** * This is called when the command is first encountered in * the CMakeLists.txt file. */ bool InitialPass(std::vector const&, - cmExecutionStatus&) CM_OVERRIDE - { - return false; - } + cmExecutionStatus&) CM_OVERRIDE; /** * This determines if the command is invoked when in script mode. diff --git a/Source/cmEndWhileCommand.cxx b/Source/cmEndWhileCommand.cxx index 7201569..9c65bbe 100644 --- a/Source/cmEndWhileCommand.cxx +++ b/Source/cmEndWhileCommand.cxx @@ -3,10 +3,9 @@ #include "cmEndWhileCommand.h" class cmExecutionStatus; -struct cmListFileArgument; -bool cmEndWhileCommand::InvokeInitialPass( - std::vector const&, cmExecutionStatus&) +bool cmEndWhileCommand::InitialPass(std::vector const&, + cmExecutionStatus&) { this->SetError("An ENDWHILE command was found outside of a proper " "WHILE ENDWHILE structure. Or its arguments did not " diff --git a/Source/cmEndWhileCommand.h b/Source/cmEndWhileCommand.h index d4e97b4..484d7c7 100644 --- a/Source/cmEndWhileCommand.h +++ b/Source/cmEndWhileCommand.h @@ -10,7 +10,6 @@ #include "cmCommand.h" class cmExecutionStatus; -struct cmListFileArgument; /** \class cmEndWhileCommand * \brief ends a while loop @@ -26,21 +25,11 @@ public: cmCommand* Clone() CM_OVERRIDE { return new cmEndWhileCommand; } /** - * Override cmCommand::InvokeInitialPass to get arguments before - * expansion. - */ - bool InvokeInitialPass(std::vector const& args, - cmExecutionStatus& status) CM_OVERRIDE; - - /** * This is called when the command is first encountered in * the CMakeLists.txt file. */ bool InitialPass(std::vector const&, - cmExecutionStatus&) CM_OVERRIDE - { - return false; - } + cmExecutionStatus&) CM_OVERRIDE; /** * This determines if the command is invoked when in script mode. -- cgit v0.12 From 67303794f0bd36912cd9e7e7d0402c3c6fc85a11 Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Sun, 27 Nov 2016 20:38:57 +0100 Subject: Combine all unexpected commands to a single class --- Source/CMakeLists.txt | 16 ++------------- Source/cmCommands.cxx | 43 ++++++++++++++++++++++++++------------- Source/cmElseCommand.cxx | 14 ------------- Source/cmElseCommand.h | 45 ----------------------------------------- Source/cmElseIfCommand.cxx | 13 ------------ Source/cmElseIfCommand.h | 45 ----------------------------------------- Source/cmEndForEachCommand.cxx | 14 ------------- Source/cmEndForEachCommand.h | 45 ----------------------------------------- Source/cmEndFunctionCommand.cxx | 14 ------------- Source/cmEndFunctionCommand.h | 45 ----------------------------------------- Source/cmEndIfCommand.cxx | 24 ---------------------- Source/cmEndIfCommand.h | 45 ----------------------------------------- Source/cmEndMacroCommand.cxx | 14 ------------- Source/cmEndMacroCommand.h | 45 ----------------------------------------- Source/cmEndWhileCommand.cxx | 14 ------------- Source/cmEndWhileCommand.h | 45 ----------------------------------------- Source/cmUnexpectedCommand.cxx | 22 ++++++++++++++++++++ Source/cmUnexpectedCommand.h | 40 ++++++++++++++++++++++++++++++++++++ bootstrap | 7 +------ 19 files changed, 94 insertions(+), 456 deletions(-) delete mode 100644 Source/cmElseCommand.cxx delete mode 100644 Source/cmElseCommand.h delete mode 100644 Source/cmElseIfCommand.cxx delete mode 100644 Source/cmElseIfCommand.h delete mode 100644 Source/cmEndForEachCommand.cxx delete mode 100644 Source/cmEndForEachCommand.h delete mode 100644 Source/cmEndFunctionCommand.cxx delete mode 100644 Source/cmEndFunctionCommand.h delete mode 100644 Source/cmEndIfCommand.cxx delete mode 100644 Source/cmEndIfCommand.h delete mode 100644 Source/cmEndMacroCommand.cxx delete mode 100644 Source/cmEndMacroCommand.h delete mode 100644 Source/cmEndWhileCommand.cxx delete mode 100644 Source/cmEndWhileCommand.h create mode 100644 Source/cmUnexpectedCommand.cxx create mode 100644 Source/cmUnexpectedCommand.h diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index f7e0944..5b381b4 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -440,24 +440,10 @@ set(SRCS cmCreateTestSourceList.h cmDefinePropertyCommand.cxx cmDefinePropertyCommand.h - cmElseCommand.cxx - cmElseCommand.h - cmElseIfCommand.cxx - cmElseIfCommand.h cmEnableLanguageCommand.cxx cmEnableLanguageCommand.h cmEnableTestingCommand.cxx cmEnableTestingCommand.h - cmEndForEachCommand.cxx - cmEndForEachCommand.h - cmEndFunctionCommand.cxx - cmEndFunctionCommand.h - cmEndIfCommand.cxx - cmEndIfCommand.h - cmEndMacroCommand.cxx - cmEndMacroCommand.h - cmEndWhileCommand.cxx - cmEndWhileCommand.h cmExecProgramCommand.cxx cmExecProgramCommand.h cmExecuteProcessCommand.cxx @@ -612,6 +598,8 @@ set(SRCS cmTryCompileCommand.h cmTryRunCommand.cxx cmTryRunCommand.h + cmUnexpectedCommand.cxx + cmUnexpectedCommand.h cmUnsetCommand.cxx cmUnsetCommand.h cmUseMangledMesaCommand.cxx diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index 103e72c..4c5b093 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -18,14 +18,8 @@ #include "cmContinueCommand.h" #include "cmCreateTestSourceList.h" #include "cmDefinePropertyCommand.h" -#include "cmElseCommand.h" #include "cmEnableLanguageCommand.h" #include "cmEnableTestingCommand.h" -#include "cmEndForEachCommand.h" -#include "cmEndFunctionCommand.h" -#include "cmEndIfCommand.h" -#include "cmEndMacroCommand.h" -#include "cmEndWhileCommand.h" #include "cmExecProgramCommand.h" #include "cmExecuteProcessCommand.h" #include "cmFileCommand.h" @@ -74,6 +68,7 @@ #include "cmTargetLinkLibrariesCommand.h" #include "cmTryCompileCommand.h" #include "cmTryRunCommand.h" +#include "cmUnexpectedCommand.h" #include "cmUnsetCommand.h" #include "cmWhileCommand.h" @@ -82,7 +77,6 @@ #include "cmAuxSourceDirectoryCommand.h" #include "cmBuildNameCommand.h" #include "cmCMakeHostSystemInformationCommand.h" -#include "cmElseIfCommand.h" #include "cmExportCommand.h" #include "cmExportLibraryDependenciesCommand.h" #include "cmFLTKWrapUICommand.h" @@ -130,14 +124,8 @@ std::vector GetPredefinedCommands() commands.push_back(new cmContinueCommand); commands.push_back(new cmCreateTestSourceList); commands.push_back(new cmDefinePropertyCommand); - commands.push_back(new cmElseCommand); commands.push_back(new cmEnableLanguageCommand); commands.push_back(new cmEnableTestingCommand); - commands.push_back(new cmEndForEachCommand); - commands.push_back(new cmEndFunctionCommand); - commands.push_back(new cmEndIfCommand); - commands.push_back(new cmEndMacroCommand); - commands.push_back(new cmEndWhileCommand); commands.push_back(new cmExecProgramCommand); commands.push_back(new cmExecuteProcessCommand); commands.push_back(new cmFileCommand); @@ -189,12 +177,39 @@ std::vector GetPredefinedCommands() commands.push_back(new cmUnsetCommand); commands.push_back(new cmWhileCommand); + commands.push_back(new cmUnexpectedCommand( + "else", "An ELSE command was found outside of a proper " + "IF ENDIF structure. Or its arguments did not match " + "the opening IF command.")); + commands.push_back(new cmUnexpectedCommand( + "elseif", "An ELSEIF command was found outside of a proper " + "IF ENDIF structure.")); + commands.push_back(new cmUnexpectedCommand( + "endforeach", "An ENDFOREACH command was found outside of a proper " + "FOREACH ENDFOREACH structure. Or its arguments did " + "not match the opening FOREACH command.")); + commands.push_back(new cmUnexpectedCommand( + "endfunction", "An ENDFUNCTION command was found outside of a proper " + "FUNCTION ENDFUNCTION structure. Or its arguments did not " + "match the opening FUNCTION command.")); + commands.push_back(new cmUnexpectedCommand( + "endif", "An ENDIF command was found outside of a proper " + "IF ENDIF structure. Or its arguments did not match " + "the opening IF command.")); + commands.push_back(new cmUnexpectedCommand( + "endmacro", "An ENDMACRO command was found outside of a proper " + "MACRO ENDMACRO structure. Or its arguments did not " + "match the opening MACRO command.")); + commands.push_back(new cmUnexpectedCommand( + "endwhile", "An ENDWHILE command was found outside of a proper " + "WHILE ENDWHILE structure. Or its arguments did not " + "match the opening WHILE command.")); + #if defined(CMAKE_BUILD_WITH_CMAKE) commands.push_back(new cmAddCompileOptionsCommand); commands.push_back(new cmAuxSourceDirectoryCommand); commands.push_back(new cmBuildNameCommand); commands.push_back(new cmCMakeHostSystemInformationCommand); - commands.push_back(new cmElseIfCommand); commands.push_back(new cmExportCommand); commands.push_back(new cmExportLibraryDependenciesCommand); commands.push_back(new cmFLTKWrapUICommand); diff --git a/Source/cmElseCommand.cxx b/Source/cmElseCommand.cxx deleted file mode 100644 index 207777e..0000000 --- a/Source/cmElseCommand.cxx +++ /dev/null @@ -1,14 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmElseCommand.h" - -class cmExecutionStatus; - -bool cmElseCommand::InitialPass(std::vector const&, - cmExecutionStatus&) -{ - this->SetError("An ELSE command was found outside of a proper " - "IF ENDIF structure. Or its arguments did not match " - "the opening IF command."); - return false; -} diff --git a/Source/cmElseCommand.h b/Source/cmElseCommand.h deleted file mode 100644 index c0162ad..0000000 --- a/Source/cmElseCommand.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#ifndef cmElseCommand_h -#define cmElseCommand_h - -#include -#include -#include - -#include "cmCommand.h" - -class cmExecutionStatus; - -/** \class cmElseCommand - * \brief ends an if block - * - * cmElseCommand ends an if block - */ -class cmElseCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - cmCommand* Clone() CM_OVERRIDE { return new cmElseCommand; } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) CM_OVERRIDE; - - /** - * This determines if the command is invoked when in script mode. - */ - bool IsScriptable() const CM_OVERRIDE { return true; } - - /** - * The name of the command as specified in CMakeList.txt. - */ - std::string GetName() const CM_OVERRIDE { return "else"; } -}; - -#endif diff --git a/Source/cmElseIfCommand.cxx b/Source/cmElseIfCommand.cxx deleted file mode 100644 index 1c32248..0000000 --- a/Source/cmElseIfCommand.cxx +++ /dev/null @@ -1,13 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmElseIfCommand.h" - -class cmExecutionStatus; - -bool cmElseIfCommand::InitialPass(std::vector const&, - cmExecutionStatus&) -{ - this->SetError("An ELSEIF command was found outside of a proper " - "IF ENDIF structure."); - return false; -} diff --git a/Source/cmElseIfCommand.h b/Source/cmElseIfCommand.h deleted file mode 100644 index 3f1ddde..0000000 --- a/Source/cmElseIfCommand.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#ifndef cmElseIfCommand_h -#define cmElseIfCommand_h - -#include -#include -#include - -#include "cmCommand.h" - -class cmExecutionStatus; - -/** \class cmElseIfCommand - * \brief ends an if block - * - * cmElseIfCommand ends an if block - */ -class cmElseIfCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - cmCommand* Clone() CM_OVERRIDE { return new cmElseIfCommand; } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) CM_OVERRIDE; - - /** - * This determines if the command is invoked when in script mode. - */ - bool IsScriptable() const CM_OVERRIDE { return true; } - - /** - * The name of the command as specified in CMakeList.txt. - */ - std::string GetName() const CM_OVERRIDE { return "elseif"; } -}; - -#endif diff --git a/Source/cmEndForEachCommand.cxx b/Source/cmEndForEachCommand.cxx deleted file mode 100644 index 81a37c3..0000000 --- a/Source/cmEndForEachCommand.cxx +++ /dev/null @@ -1,14 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmEndForEachCommand.h" - -class cmExecutionStatus; - -bool cmEndForEachCommand::InitialPass(std::vector const&, - cmExecutionStatus&) -{ - this->SetError("An ENDFOREACH command was found outside of a proper " - "FOREACH ENDFOREACH structure. Or its arguments did " - "not match the opening FOREACH command."); - return false; -} diff --git a/Source/cmEndForEachCommand.h b/Source/cmEndForEachCommand.h deleted file mode 100644 index e480e72..0000000 --- a/Source/cmEndForEachCommand.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#ifndef cmEndForEachCommand_h -#define cmEndForEachCommand_h - -#include -#include -#include - -#include "cmCommand.h" - -class cmExecutionStatus; - -/** \class cmEndForEachCommand - * \brief ends an if block - * - * cmEndForEachCommand ends an if block - */ -class cmEndForEachCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - cmCommand* Clone() CM_OVERRIDE { return new cmEndForEachCommand; } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const&, - cmExecutionStatus&) CM_OVERRIDE; - - /** - * This determines if the command is invoked when in script mode. - */ - bool IsScriptable() const CM_OVERRIDE { return true; } - - /** - * The name of the command as specified in CMakeList.txt. - */ - std::string GetName() const CM_OVERRIDE { return "endforeach"; } -}; - -#endif diff --git a/Source/cmEndFunctionCommand.cxx b/Source/cmEndFunctionCommand.cxx deleted file mode 100644 index 2d6b192..0000000 --- a/Source/cmEndFunctionCommand.cxx +++ /dev/null @@ -1,14 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmEndFunctionCommand.h" - -class cmExecutionStatus; - -bool cmEndFunctionCommand::InitialPass(std::vector const&, - cmExecutionStatus&) -{ - this->SetError("An ENDFUNCTION command was found outside of a proper " - "FUNCTION ENDFUNCTION structure. Or its arguments did not " - "match the opening FUNCTION command."); - return false; -} diff --git a/Source/cmEndFunctionCommand.h b/Source/cmEndFunctionCommand.h deleted file mode 100644 index b3cf8e6..0000000 --- a/Source/cmEndFunctionCommand.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#ifndef cmEndFunctionCommand_h -#define cmEndFunctionCommand_h - -#include -#include -#include - -#include "cmCommand.h" - -class cmExecutionStatus; - -/** \class cmEndFunctionCommand - * \brief ends an if block - * - * cmEndFunctionCommand ends an if block - */ -class cmEndFunctionCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - cmCommand* Clone() CM_OVERRIDE { return new cmEndFunctionCommand; } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const&, - cmExecutionStatus&) CM_OVERRIDE; - - /** - * This determines if the command is invoked when in script mode. - */ - bool IsScriptable() const CM_OVERRIDE { return true; } - - /** - * The name of the command as specified in CMakeList.txt. - */ - std::string GetName() const CM_OVERRIDE { return "endfunction"; } -}; - -#endif diff --git a/Source/cmEndIfCommand.cxx b/Source/cmEndIfCommand.cxx deleted file mode 100644 index 50c2b42..0000000 --- a/Source/cmEndIfCommand.cxx +++ /dev/null @@ -1,24 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmEndIfCommand.h" - -#include // required for atof - -#include "cmMakefile.h" - -class cmExecutionStatus; - -bool cmEndIfCommand::InitialPass(std::vector const&, - cmExecutionStatus&) -{ - const char* versionValue = - this->Makefile->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION"); - if (!versionValue || (atof(versionValue) <= 1.4)) { - return true; - } - - this->SetError("An ENDIF command was found outside of a proper " - "IF ENDIF structure. Or its arguments did not match " - "the opening IF command."); - return false; -} diff --git a/Source/cmEndIfCommand.h b/Source/cmEndIfCommand.h deleted file mode 100644 index dfd6049..0000000 --- a/Source/cmEndIfCommand.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#ifndef cmEndIfCommand_h -#define cmEndIfCommand_h - -#include -#include -#include - -#include "cmCommand.h" - -class cmExecutionStatus; - -/** \class cmEndIfCommand - * \brief ends an if block - * - * cmEndIfCommand ends an if block - */ -class cmEndIfCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - cmCommand* Clone() CM_OVERRIDE { return new cmEndIfCommand; } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) CM_OVERRIDE; - - /** - * This determines if the command is invoked when in script mode. - */ - bool IsScriptable() const CM_OVERRIDE { return true; } - - /** - * The name of the command as specified in CMakeList.txt. - */ - std::string GetName() const CM_OVERRIDE { return "endif"; } -}; - -#endif diff --git a/Source/cmEndMacroCommand.cxx b/Source/cmEndMacroCommand.cxx deleted file mode 100644 index 6429d7c..0000000 --- a/Source/cmEndMacroCommand.cxx +++ /dev/null @@ -1,14 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmEndMacroCommand.h" - -class cmExecutionStatus; - -bool cmEndMacroCommand::InitialPass(std::vector const&, - cmExecutionStatus&) -{ - this->SetError("An ENDMACRO command was found outside of a proper " - "MACRO ENDMACRO structure. Or its arguments did not " - "match the opening MACRO command."); - return false; -} diff --git a/Source/cmEndMacroCommand.h b/Source/cmEndMacroCommand.h deleted file mode 100644 index bd7cdbd..0000000 --- a/Source/cmEndMacroCommand.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#ifndef cmEndMacroCommand_h -#define cmEndMacroCommand_h - -#include -#include -#include - -#include "cmCommand.h" - -class cmExecutionStatus; - -/** \class cmEndMacroCommand - * \brief ends an if block - * - * cmEndMacroCommand ends an if block - */ -class cmEndMacroCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - cmCommand* Clone() CM_OVERRIDE { return new cmEndMacroCommand; } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const&, - cmExecutionStatus&) CM_OVERRIDE; - - /** - * This determines if the command is invoked when in script mode. - */ - bool IsScriptable() const CM_OVERRIDE { return true; } - - /** - * The name of the command as specified in CMakeList.txt. - */ - std::string GetName() const CM_OVERRIDE { return "endmacro"; } -}; - -#endif diff --git a/Source/cmEndWhileCommand.cxx b/Source/cmEndWhileCommand.cxx deleted file mode 100644 index 9c65bbe..0000000 --- a/Source/cmEndWhileCommand.cxx +++ /dev/null @@ -1,14 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmEndWhileCommand.h" - -class cmExecutionStatus; - -bool cmEndWhileCommand::InitialPass(std::vector const&, - cmExecutionStatus&) -{ - this->SetError("An ENDWHILE command was found outside of a proper " - "WHILE ENDWHILE structure. Or its arguments did not " - "match the opening WHILE command."); - return false; -} diff --git a/Source/cmEndWhileCommand.h b/Source/cmEndWhileCommand.h deleted file mode 100644 index 484d7c7..0000000 --- a/Source/cmEndWhileCommand.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#ifndef cmEndWhileCommand_h -#define cmEndWhileCommand_h - -#include -#include -#include - -#include "cmCommand.h" - -class cmExecutionStatus; - -/** \class cmEndWhileCommand - * \brief ends a while loop - * - * cmEndWhileCommand ends a while loop - */ -class cmEndWhileCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - cmCommand* Clone() CM_OVERRIDE { return new cmEndWhileCommand; } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const&, - cmExecutionStatus&) CM_OVERRIDE; - - /** - * This determines if the command is invoked when in script mode. - */ - bool IsScriptable() const CM_OVERRIDE { return true; } - - /** - * The name of the command as specified in CMakeList.txt. - */ - std::string GetName() const CM_OVERRIDE { return "endwhile"; } -}; - -#endif diff --git a/Source/cmUnexpectedCommand.cxx b/Source/cmUnexpectedCommand.cxx new file mode 100644 index 0000000..a8de9e6 --- /dev/null +++ b/Source/cmUnexpectedCommand.cxx @@ -0,0 +1,22 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include "cmUnexpectedCommand.h" + +#include + +#include "cmMakefile.h" + +class cmExecutionStatus; + +bool cmUnexpectedCommand::InitialPass(std::vector const&, + cmExecutionStatus&) +{ + const char* versionValue = + this->Makefile->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION"); + if (this->Name == "endif" && (!versionValue || atof(versionValue) <= 1.4)) { + return true; + } + + this->SetError(this->Error); + return false; +} diff --git a/Source/cmUnexpectedCommand.h b/Source/cmUnexpectedCommand.h new file mode 100644 index 0000000..897dfb6 --- /dev/null +++ b/Source/cmUnexpectedCommand.h @@ -0,0 +1,40 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#ifndef cmUnexpectedCommand_h +#define cmUnexpectedCommand_h + +#include +#include +#include + +#include "cmCommand.h" + +class cmExecutionStatus; + +class cmUnexpectedCommand : public cmCommand +{ +public: + cmUnexpectedCommand(std::string const& name, const char* error) + : Name(name) + , Error(error) + { + } + + cmCommand* Clone() CM_OVERRIDE + { + return new cmUnexpectedCommand(this->Name, this->Error); + } + + bool InitialPass(std::vector const& args, + cmExecutionStatus& status) CM_OVERRIDE; + + bool IsScriptable() const CM_OVERRIDE { return true; } + + std::string GetName() const CM_OVERRIDE { return this->Name; } + +private: + std::string Name; + const char* Error; +}; + +#endif diff --git a/bootstrap b/bootstrap index ec081fa..8063edb 100755 --- a/bootstrap +++ b/bootstrap @@ -277,14 +277,8 @@ CMAKE_CXX_SOURCES="\ cmDepends \ cmDependsC \ cmDocumentationFormatter \ - cmElseCommand \ cmEnableLanguageCommand \ cmEnableTestingCommand \ - cmEndForEachCommand \ - cmEndFunctionCommand \ - cmEndIfCommand \ - cmEndMacroCommand \ - cmEndWhileCommand \ cmExecProgramCommand \ cmExecuteProcessCommand \ cmExpandedCommandArgument \ @@ -406,6 +400,7 @@ CMAKE_CXX_SOURCES="\ cmTimestamp \ cmTryCompileCommand \ cmTryRunCommand \ + cmUnexpectedCommand \ cmUnsetCommand \ cmVersion \ cmWhileCommand \ -- cgit v0.12