diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 0316532123..8117916832 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -662,8 +662,6 @@ set(SRCS cmTryCompileCommand.h cmTryRunCommand.cxx cmTryRunCommand.h - cmUnexpectedCommand.cxx - cmUnexpectedCommand.h cmUnsetCommand.cxx cmUnsetCommand.h cmUseMangledMesaCommand.cxx diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 57ae324cf4..82b0a52cf1 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -5,6 +5,7 @@ #include "cmsys/RegularExpression.hxx" #include #include +#include #include #include @@ -15,12 +16,13 @@ #include "cmCommand.h" #include "cmDefinitions.h" #include "cmDisallowedCommand.h" +#include "cmExecutionStatus.h" #include "cmGlobVerificationManager.h" #include "cmListFileCache.h" +#include "cmMakefile.h" #include "cmStatePrivate.h" #include "cmStateSnapshot.h" #include "cmSystemTools.h" -#include "cmUnexpectedCommand.h" #include "cmake.h" cmState::cmState() @@ -419,11 +421,15 @@ void cmState::SetIsGeneratorMultiConfig(bool b) void cmState::AddBuiltinCommand(std::string const& name, std::unique_ptr command) +{ + this->AddBuiltinCommand(name, cmLegacyCommandWrapper(std::move(command))); +} + +void cmState::AddBuiltinCommand(std::string const& name, Command command) { assert(name == cmSystemTools::LowerCase(name)); assert(this->BuiltinCommands.find(name) == this->BuiltinCommands.end()); - this->BuiltinCommands.emplace(name, - cmLegacyCommandWrapper(std::move(command))); + this->BuiltinCommands.emplace(name, std::move(command)); } void cmState::AddDisallowedCommand(std::string const& name, @@ -438,8 +444,18 @@ void cmState::AddDisallowedCommand(std::string const& name, void cmState::AddUnexpectedCommand(std::string const& name, const char* error) { - this->AddBuiltinCommand(name, - cm::make_unique(name, error)); + this->AddBuiltinCommand( + name, + [name, error](std::vector const&, + cmExecutionStatus& status) -> bool { + const char* versionValue = + status.GetMakefile().GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION"); + if (name == "endif" && (!versionValue || atof(versionValue) <= 1.4)) { + return true; + } + status.SetError(error); + return false; + }); } void cmState::AddScriptedCommand(std::string const& name, diff --git a/Source/cmState.h b/Source/cmState.h index ed70bd6f94..a6e9386d8e 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -153,6 +153,7 @@ public: void AddBuiltinCommand(std::string const& name, std::unique_ptr command); + void AddBuiltinCommand(std::string const& name, Command command); void AddDisallowedCommand(std::string const& name, std::unique_ptr command, cmPolicies::PolicyID policy, const char* message); diff --git a/Source/cmUnexpectedCommand.cxx b/Source/cmUnexpectedCommand.cxx deleted file mode 100644 index a8de9e689a..0000000000 --- a/Source/cmUnexpectedCommand.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 "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 deleted file mode 100644 index 6e4cee507b..0000000000 --- a/Source/cmUnexpectedCommand.h +++ /dev/null @@ -1,40 +0,0 @@ -/* 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" // IWYU pragma: keep - -#include -#include -#include - -#include "cm_memory.hxx" - -#include "cmCommand.h" - -class cmExecutionStatus; - -class cmUnexpectedCommand : public cmCommand -{ -public: - cmUnexpectedCommand(std::string name, const char* error) - : Name(std::move(name)) - , Error(error) - { - } - - std::unique_ptr Clone() override - { - return cm::make_unique(this->Name, this->Error); - } - - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; - -private: - std::string Name; - const char* Error; -}; - -#endif diff --git a/bootstrap b/bootstrap index c2194febf2..bb5229b5f4 100755 --- a/bootstrap +++ b/bootstrap @@ -440,7 +440,6 @@ CMAKE_CXX_SOURCES="\ cmTimestamp \ cmTryCompileCommand \ cmTryRunCommand \ - cmUnexpectedCommand \ cmUnsetCommand \ cmUVHandlePtr \ cmUVProcessChain \