ENH: Save command that macro overwrites
This commit is contained in:
parent
a95a4b000d
commit
24a5c0a72e
@ -16,6 +16,8 @@
|
|||||||
=========================================================================*/
|
=========================================================================*/
|
||||||
#include "cmMacroCommand.h"
|
#include "cmMacroCommand.h"
|
||||||
|
|
||||||
|
#include "cmake.h"
|
||||||
|
|
||||||
// define the class for macro commands
|
// define the class for macro commands
|
||||||
class cmMacroHelperCommand : public cmCommand
|
class cmMacroHelperCommand : public cmCommand
|
||||||
{
|
{
|
||||||
@ -37,6 +39,11 @@ public:
|
|||||||
return newC;
|
return newC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This determines if the command is invoked when in script mode.
|
||||||
|
*/
|
||||||
|
virtual bool IsScriptable() { return true; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is called when the command is first encountered in
|
* This is called when the command is first encountered in
|
||||||
* the CMakeLists.txt file.
|
* the CMakeLists.txt file.
|
||||||
@ -265,6 +272,8 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf)
|
|||||||
cmMacroHelperCommand *f = new cmMacroHelperCommand();
|
cmMacroHelperCommand *f = new cmMacroHelperCommand();
|
||||||
f->m_Args = this->m_Args;
|
f->m_Args = this->m_Args;
|
||||||
f->m_Functions = this->m_Functions;
|
f->m_Functions = this->m_Functions;
|
||||||
|
std::string newName = "_" + this->m_Args[0];
|
||||||
|
mf.GetCMakeInstance()->RenameCommand(this->m_Args[0].c_str(), newName.c_str());
|
||||||
mf.AddCommand(f);
|
mf.AddCommand(f);
|
||||||
|
|
||||||
// remove the function blocker now that the macro is defined
|
// remove the function blocker now that the macro is defined
|
||||||
|
@ -173,6 +173,20 @@ cmCommand *cmake::GetCommand(const char *name)
|
|||||||
return rm;
|
return rm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmake::RenameCommand(const char*oldName, const char* newName)
|
||||||
|
{
|
||||||
|
// if the command already exists, free the old one
|
||||||
|
RegisteredCommandsMap::iterator pos = m_Commands.find(oldName);
|
||||||
|
if ( pos == m_Commands.end() )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_Commands.insert(RegisteredCommandsMap::value_type(newName, pos->second));
|
||||||
|
pos = m_Commands.find(oldName);
|
||||||
|
m_Commands.erase(pos);
|
||||||
|
}
|
||||||
|
|
||||||
void cmake::AddCommand(cmCommand* wg)
|
void cmake::AddCommand(cmCommand* wg)
|
||||||
{
|
{
|
||||||
std::string name = wg->GetName();
|
std::string name = wg->GetName();
|
||||||
|
@ -192,6 +192,7 @@ class cmake
|
|||||||
* Add a command to this cmake instance
|
* Add a command to this cmake instance
|
||||||
*/
|
*/
|
||||||
void AddCommand(cmCommand* );
|
void AddCommand(cmCommand* );
|
||||||
|
void RenameCommand(const char* oldName, const char* newName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a command by its name
|
* Get a command by its name
|
||||||
|
Loading…
x
Reference in New Issue
Block a user