summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastien Barre <sebastien.barre@kitware.com>2002-04-11 14:05:47 (GMT)
committerSebastien Barre <sebastien.barre@kitware.com>2002-04-11 14:05:47 (GMT)
commit9b8926925b2c50afff276d25a5ee6eadd31ec477 (patch)
treefc5dda815f4e6a00d8dfe3ada5aa6f6bfe1c4b25
parente455a83969be5ff4642a9c505f2f1c23248b01f7 (diff)
downloadCMake-9b8926925b2c50afff276d25a5ee6eadd31ec477.zip
CMake-9b8926925b2c50afff276d25a5ee6eadd31ec477.tar.gz
CMake-9b8926925b2c50afff276d25a5ee6eadd31ec477.tar.bz2
ENH: use target as source if source is empty
-rw-r--r--Source/cmAddCustomCommandCommand.cxx20
-rw-r--r--Source/cmAddCustomCommandCommand.h2
2 files changed, 13 insertions, 9 deletions
diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx
index 845ff24..f601ecc 100644
--- a/Source/cmAddCustomCommandCommand.cxx
+++ b/Source/cmAddCustomCommandCommand.cxx
@@ -21,10 +21,10 @@
bool cmAddCustomCommandCommand::InitialPass(std::vector<std::string> const& argsIn)
{
/* 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.
*/
- if (argsIn.size() < 6)
+ if (argsIn.size() < 4)
{
this->SetError("called with wrong number of arguments.");
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.
- For the moment, let's say that SOURCE, COMMAND, TARGET are always
+ For the moment, let's say that COMMAND, TARGET are always
required.
*/
- if(source.empty())
- {
- this->SetError("Wrong syntax. Empty SOURCE.");
- return false;
- }
if(command.empty())
{
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.");
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(),
command.c_str(),
command_args,
diff --git a/Source/cmAddCustomCommandCommand.h b/Source/cmAddCustomCommandCommand.h
index f65d0aa..5f73aec 100644
--- a/Source/cmAddCustomCommandCommand.h
+++ b/Source/cmAddCustomCommandCommand.h
@@ -86,7 +86,7 @@ public:
virtual const char* GetFullDocumentation()
{
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"
"Add a custom command.";
}