mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-15 20:46:37 +08:00
cmState: introduce methods for adding builtin commands
This commit is contained in:
@@ -12,10 +12,12 @@
|
|||||||
#include "cmCacheManager.h"
|
#include "cmCacheManager.h"
|
||||||
#include "cmCommand.h"
|
#include "cmCommand.h"
|
||||||
#include "cmDefinitions.h"
|
#include "cmDefinitions.h"
|
||||||
|
#include "cmDisallowedCommand.h"
|
||||||
#include "cmListFileCache.h"
|
#include "cmListFileCache.h"
|
||||||
#include "cmStatePrivate.h"
|
#include "cmStatePrivate.h"
|
||||||
#include "cmStateSnapshot.h"
|
#include "cmStateSnapshot.h"
|
||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
|
#include "cmUnexpectedCommand.h"
|
||||||
#include "cmake.h"
|
#include "cmake.h"
|
||||||
|
|
||||||
cmState::cmState()
|
cmState::cmState()
|
||||||
@@ -410,6 +412,27 @@ void cmState::AddCommand(cmCommand* command)
|
|||||||
this->Commands.insert(std::make_pair(name, command));
|
this->Commands.insert(std::make_pair(name, command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmState::AddBuiltinCommand(std::string const& name, cmCommand* command)
|
||||||
|
{
|
||||||
|
assert(name == cmSystemTools::LowerCase(name));
|
||||||
|
assert(name == cmSystemTools::LowerCase(command->GetName()));
|
||||||
|
assert(this->Commands.find(name) == this->Commands.end());
|
||||||
|
this->Commands.insert(std::make_pair(name, command));
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmState::AddDisallowedCommand(std::string const& name, cmCommand* command,
|
||||||
|
cmPolicies::PolicyID policy,
|
||||||
|
const char* message)
|
||||||
|
{
|
||||||
|
this->AddBuiltinCommand(name,
|
||||||
|
new cmDisallowedCommand(command, policy, message));
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmState::AddUnexpectedCommand(std::string const& name, const char* error)
|
||||||
|
{
|
||||||
|
this->AddBuiltinCommand(name, new cmUnexpectedCommand(name, error));
|
||||||
|
}
|
||||||
|
|
||||||
cmCommand* cmState::GetCommand(std::string const& name) const
|
cmCommand* cmState::GetCommand(std::string const& name) const
|
||||||
{
|
{
|
||||||
cmCommand* command = CM_NULLPTR;
|
cmCommand* command = CM_NULLPTR;
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "cmDefinitions.h"
|
#include "cmDefinitions.h"
|
||||||
#include "cmLinkedTree.h"
|
#include "cmLinkedTree.h"
|
||||||
|
#include "cmPolicies.h"
|
||||||
#include "cmProperty.h"
|
#include "cmProperty.h"
|
||||||
#include "cmPropertyDefinitionMap.h"
|
#include "cmPropertyDefinitionMap.h"
|
||||||
#include "cmPropertyMap.h"
|
#include "cmPropertyMap.h"
|
||||||
@@ -121,6 +122,10 @@ public:
|
|||||||
|
|
||||||
cmCommand* GetCommand(std::string const& name) const;
|
cmCommand* GetCommand(std::string const& name) const;
|
||||||
void AddCommand(cmCommand* command);
|
void AddCommand(cmCommand* command);
|
||||||
|
void AddBuiltinCommand(std::string const& name, cmCommand* command);
|
||||||
|
void AddDisallowedCommand(std::string const& name, cmCommand* command,
|
||||||
|
cmPolicies::PolicyID policy, const char* message);
|
||||||
|
void AddUnexpectedCommand(std::string const& name, const char* error);
|
||||||
void RenameCommand(std::string const& oldName, std::string const& newName);
|
void RenameCommand(std::string const& oldName, std::string const& newName);
|
||||||
void RemoveUserDefinedCommands();
|
void RemoveUserDefinedCommands();
|
||||||
std::vector<std::string> GetCommandNames() const;
|
std::vector<std::string> GetCommandNames() const;
|
||||||
|
@@ -278,6 +278,7 @@ CMAKE_CXX_SOURCES="\
|
|||||||
cmDefinitions \
|
cmDefinitions \
|
||||||
cmDepends \
|
cmDepends \
|
||||||
cmDependsC \
|
cmDependsC \
|
||||||
|
cmDisallowedCommand \
|
||||||
cmDocumentationFormatter \
|
cmDocumentationFormatter \
|
||||||
cmEnableLanguageCommand \
|
cmEnableLanguageCommand \
|
||||||
cmEnableTestingCommand \
|
cmEnableTestingCommand \
|
||||||
|
Reference in New Issue
Block a user