diff options
author | Regina Pfeifer <regina@mailbox.org> | 2019-04-07 18:40:59 (GMT) |
---|---|---|
committer | Regina Pfeifer <regina@mailbox.org> | 2019-07-21 07:25:32 (GMT) |
commit | 0101ace1319b5c97472649ec809b67299e2a46ce (patch) | |
tree | bfe5efb6d3e133e4b96994f5cd65d5417a26ff12 /Source/cmState.cxx | |
parent | 015001aaf138119f4825e3c84c0845c5127f9088 (diff) | |
download | CMake-0101ace1319b5c97472649ec809b67299e2a46ce.zip CMake-0101ace1319b5c97472649ec809b67299e2a46ce.tar.gz CMake-0101ace1319b5c97472649ec809b67299e2a46ce.tar.bz2 |
cmUnexpectedCommand: Replace with lambda expression
Diffstat (limited to 'Source/cmState.cxx')
-rw-r--r-- | Source/cmState.cxx | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 57ae324..82b0a52 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -5,6 +5,7 @@ #include "cmsys/RegularExpression.hxx" #include <algorithm> #include <assert.h> +#include <stdlib.h> #include <string.h> #include <utility> @@ -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() @@ -420,10 +422,14 @@ void cmState::SetIsGeneratorMultiConfig(bool b) void cmState::AddBuiltinCommand(std::string const& name, std::unique_ptr<cmCommand> 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<cmUnexpectedCommand>(name, error)); + this->AddBuiltinCommand( + name, + [name, error](std::vector<cmListFileArgument> 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, |