diff options
author | Brad King <brad.king@kitware.com> | 2016-11-30 13:37:22 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2016-11-30 13:37:22 (GMT) |
commit | 32e95a7b24b057e410f0d49fa10a3d05452be264 (patch) | |
tree | 32850ca3517a077ff770737be66f6c013c853388 | |
parent | d5ab04f065b85a300c348236519b4c024dd19377 (diff) | |
parent | 67303794f0bd36912cd9e7e7d0402c3c6fc85a11 (diff) | |
download | CMake-32e95a7b24b057e410f0d49fa10a3d05452be264.zip CMake-32e95a7b24b057e410f0d49fa10a3d05452be264.tar.gz CMake-32e95a7b24b057e410f0d49fa10a3d05452be264.tar.bz2 |
Merge topic 'end-commands'
67303794 Combine all unexpected commands to a single class
d23a0196 Set the error after argument expansion in end commands
1afbe7d2 Make error message of standalone endwhile command consistent
-rw-r--r-- | Source/CMakeLists.txt | 16 | ||||
-rw-r--r-- | Source/cmCommands.cxx | 43 | ||||
-rw-r--r-- | Source/cmElseCommand.cxx | 14 | ||||
-rw-r--r-- | Source/cmElseCommand.h | 45 | ||||
-rw-r--r-- | Source/cmElseIfCommand.cxx | 13 | ||||
-rw-r--r-- | Source/cmElseIfCommand.h | 45 | ||||
-rw-r--r-- | Source/cmEndForEachCommand.cxx | 15 | ||||
-rw-r--r-- | Source/cmEndForEachCommand.h | 56 | ||||
-rw-r--r-- | Source/cmEndFunctionCommand.cxx | 15 | ||||
-rw-r--r-- | Source/cmEndFunctionCommand.h | 56 | ||||
-rw-r--r-- | Source/cmEndIfCommand.cxx | 24 | ||||
-rw-r--r-- | Source/cmEndIfCommand.h | 45 | ||||
-rw-r--r-- | Source/cmEndMacroCommand.cxx | 15 | ||||
-rw-r--r-- | Source/cmEndMacroCommand.h | 56 | ||||
-rw-r--r-- | Source/cmEndWhileCommand.cxx | 22 | ||||
-rw-r--r-- | Source/cmEndWhileCommand.h | 56 | ||||
-rw-r--r-- | Source/cmUnexpectedCommand.cxx | 22 | ||||
-rw-r--r-- | Source/cmUnexpectedCommand.h | 40 | ||||
-rw-r--r-- | Tests/RunCMake/while/EndAlone-stderr.txt | 2 | ||||
-rwxr-xr-x | bootstrap | 7 |
20 files changed, 95 insertions, 512 deletions
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<cmCommand*> 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<cmCommand*> 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<std::string> 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 <cmConfigure.h> -#include <string> -#include <vector> - -#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<std::string> 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<std::string> 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 <cmConfigure.h> -#include <string> -#include <vector> - -#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<std::string> 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 fe6a7f3..0000000 --- a/Source/cmEndForEachCommand.cxx +++ /dev/null @@ -1,15 +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; -struct cmListFileArgument; - -bool cmEndForEachCommand::InvokeInitialPass( - std::vector<cmListFileArgument> 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 772a139..0000000 --- a/Source/cmEndForEachCommand.h +++ /dev/null @@ -1,56 +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 <cmConfigure.h> -#include <string> -#include <vector> - -#include "cmCommand.h" - -class cmExecutionStatus; -struct cmListFileArgument; - -/** \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; } - - /** - * Override cmCommand::InvokeInitialPass to get arguments before - * expansion. - */ - bool InvokeInitialPass(std::vector<cmListFileArgument> const&, - cmExecutionStatus&) CM_OVERRIDE; - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector<std::string> const&, - cmExecutionStatus&) CM_OVERRIDE - { - return false; - } - - /** - * 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 6adb42b..0000000 --- a/Source/cmEndFunctionCommand.cxx +++ /dev/null @@ -1,15 +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; -struct cmListFileArgument; - -bool cmEndFunctionCommand::InvokeInitialPass( - std::vector<cmListFileArgument> 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 2599637..0000000 --- a/Source/cmEndFunctionCommand.h +++ /dev/null @@ -1,56 +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 <cmConfigure.h> -#include <string> -#include <vector> - -#include "cmCommand.h" - -class cmExecutionStatus; -struct cmListFileArgument; - -/** \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; } - - /** - * Override cmCommand::InvokeInitialPass to get arguments before - * expansion. - */ - bool InvokeInitialPass(std::vector<cmListFileArgument> const&, - cmExecutionStatus&) CM_OVERRIDE; - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector<std::string> const&, - cmExecutionStatus&) CM_OVERRIDE - { - return false; - } - - /** - * 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 <stdlib.h> // required for atof - -#include "cmMakefile.h" - -class cmExecutionStatus; - -bool cmEndIfCommand::InitialPass(std::vector<std::string> 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 <cmConfigure.h> -#include <string> -#include <vector> - -#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<std::string> 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 046b0af..0000000 --- a/Source/cmEndMacroCommand.cxx +++ /dev/null @@ -1,15 +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; -struct cmListFileArgument; - -bool cmEndMacroCommand::InvokeInitialPass( - std::vector<cmListFileArgument> 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 3c462d4..0000000 --- a/Source/cmEndMacroCommand.h +++ /dev/null @@ -1,56 +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 <cmConfigure.h> -#include <string> -#include <vector> - -#include "cmCommand.h" - -class cmExecutionStatus; -struct cmListFileArgument; - -/** \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; } - - /** - * Override cmCommand::InvokeInitialPass to get arguments before - * expansion. - */ - bool InvokeInitialPass(std::vector<cmListFileArgument> const&, - cmExecutionStatus&) CM_OVERRIDE; - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector<std::string> const&, - cmExecutionStatus&) CM_OVERRIDE - { - return false; - } - - /** - * 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 5623f33..0000000 --- a/Source/cmEndWhileCommand.cxx +++ /dev/null @@ -1,22 +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" - -#include "cmListFileCache.h" - -class cmExecutionStatus; - -bool cmEndWhileCommand::InvokeInitialPass( - std::vector<cmListFileArgument> const& args, 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."); - } - - return false; -} diff --git a/Source/cmEndWhileCommand.h b/Source/cmEndWhileCommand.h deleted file mode 100644 index d4e97b4..0000000 --- a/Source/cmEndWhileCommand.h +++ /dev/null @@ -1,56 +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 <cmConfigure.h> -#include <string> -#include <vector> - -#include "cmCommand.h" - -class cmExecutionStatus; -struct cmListFileArgument; - -/** \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; } - - /** - * Override cmCommand::InvokeInitialPass to get arguments before - * expansion. - */ - bool InvokeInitialPass(std::vector<cmListFileArgument> const& args, - cmExecutionStatus& status) CM_OVERRIDE; - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector<std::string> const&, - cmExecutionStatus&) CM_OVERRIDE - { - return false; - } - - /** - * 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 <stdlib.h> + +#include "cmMakefile.h" + +class cmExecutionStatus; + +bool cmUnexpectedCommand::InitialPass(std::vector<std::string> 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 <cmConfigure.h> +#include <string> +#include <vector> + +#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<std::string> 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/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\)$ @@ -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 \ |