ENH: use target as source if source is empty
This commit is contained in:
parent
e455a83969
commit
9b8926925b
|
@ -21,10 +21,10 @@
|
||||||
bool cmAddCustomCommandCommand::InitialPass(std::vector<std::string> const& argsIn)
|
bool cmAddCustomCommandCommand::InitialPass(std::vector<std::string> const& argsIn)
|
||||||
{
|
{
|
||||||
/* Let's complain at the end of this function about the lack of a particular
|
/* Let's complain at the end of this function about the lack of a particular
|
||||||
arg. For the moment, let's say that SOURCE, COMMAND, TARGET are always
|
arg. For the moment, let's say that COMMAND, TARGET are always
|
||||||
required.
|
required.
|
||||||
*/
|
*/
|
||||||
if (argsIn.size() < 6)
|
if (argsIn.size() < 4)
|
||||||
{
|
{
|
||||||
this->SetError("called with wrong number of arguments.");
|
this->SetError("called with wrong number of arguments.");
|
||||||
return false;
|
return false;
|
||||||
|
@ -106,15 +106,10 @@ bool cmAddCustomCommandCommand::InitialPass(std::vector<std::string> const& args
|
||||||
}
|
}
|
||||||
|
|
||||||
/* At this point we could complain about the lack of arguments.
|
/* At this point we could complain about the lack of arguments.
|
||||||
For the moment, let's say that SOURCE, COMMAND, TARGET are always
|
For the moment, let's say that COMMAND, TARGET are always
|
||||||
required.
|
required.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if(source.empty())
|
|
||||||
{
|
|
||||||
this->SetError("Wrong syntax. Empty SOURCE.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(command.empty())
|
if(command.empty())
|
||||||
{
|
{
|
||||||
this->SetError("Wrong syntax. Empty COMMAND.");
|
this->SetError("Wrong syntax. Empty COMMAND.");
|
||||||
|
@ -125,6 +120,15 @@ bool cmAddCustomCommandCommand::InitialPass(std::vector<std::string> const& args
|
||||||
this->SetError("Wrong syntax. Empty TARGET.");
|
this->SetError("Wrong syntax. Empty TARGET.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If source is empty, use target as source, so that this command
|
||||||
|
// can be used to just attach a commmand to a target
|
||||||
|
|
||||||
|
if(source.empty())
|
||||||
|
{
|
||||||
|
source = target;
|
||||||
|
}
|
||||||
|
|
||||||
m_Makefile->AddCustomCommand(source.c_str(),
|
m_Makefile->AddCustomCommand(source.c_str(),
|
||||||
command.c_str(),
|
command.c_str(),
|
||||||
command_args,
|
command_args,
|
||||||
|
|
|
@ -86,7 +86,7 @@ public:
|
||||||
virtual const char* GetFullDocumentation()
|
virtual const char* GetFullDocumentation()
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
"ADD_CUSTOM_COMMAND(SOURCE source COMMAND command TARGET target "
|
"ADD_CUSTOM_COMMAND([SOURCE source] COMMAND command TARGET target "
|
||||||
"[ARGS [args...]] [DEPENDS [depends...]] [OUTPUTS [outputs...]])\n"
|
"[ARGS [args...]] [DEPENDS [depends...]] [OUTPUTS [outputs...]])\n"
|
||||||
"Add a custom command.";
|
"Add a custom command.";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue