summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2006-10-04 22:10:30 (GMT)
committerBrad King <brad.king@kitware.com>2006-10-04 22:10:30 (GMT)
commit5a6b0792cd5b3dd16b8a94091db15e02e9b4a00b (patch)
tree0555eb82a57d07bddefdfb3cf3760f1042fa763d /Source
parent168591e72dd3d67ae2ced24582e6b117a9a2ac4f (diff)
downloadCMake-5a6b0792cd5b3dd16b8a94091db15e02e9b4a00b.zip
CMake-5a6b0792cd5b3dd16b8a94091db15e02e9b4a00b.tar.gz
CMake-5a6b0792cd5b3dd16b8a94091db15e02e9b4a00b.tar.bz2
ENH: Added COMMENT option to ADD_CUSTOM_TARGET. This addresses bug#3461.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmAddCustomTargetCommand.cxx13
-rw-r--r--Source/cmAddCustomTargetCommand.h5
-rw-r--r--Source/cmMakefile.cxx11
-rw-r--r--Source/cmMakefile.h3
4 files changed, 26 insertions, 6 deletions
diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx
index 9d73cd0..4141509 100644
--- a/Source/cmAddCustomTargetCommand.cxx
+++ b/Source/cmAddCustomTargetCommand.cxx
@@ -59,12 +59,15 @@ bool cmAddCustomTargetCommand::InitialPass(
std::vector<std::string> depends;
std::string working_directory;
bool verbatim = false;
+ std::string comment_buffer;
+ const char* comment = 0;
// Keep track of parser state.
enum tdoing {
doing_command,
doing_depends,
doing_working_directory,
+ doing_comment,
doing_verbatim
};
tdoing doing = doing_command;
@@ -99,6 +102,10 @@ bool cmAddCustomTargetCommand::InitialPass(
doing = doing_verbatim;
verbatim = true;
}
+ else if (copy == "COMMENT")
+ {
+ doing = doing_comment;
+ }
else if(copy == "COMMAND")
{
doing = doing_command;
@@ -123,6 +130,10 @@ bool cmAddCustomTargetCommand::InitialPass(
case doing_depends:
depends.push_back(copy);
break;
+ case doing_comment:
+ comment_buffer = copy;
+ comment = comment_buffer.c_str();
+ break;
default:
this->SetError("Wrong syntax. Unknown type of argument.");
return false;
@@ -151,7 +162,7 @@ bool cmAddCustomTargetCommand::InitialPass(
bool escapeOldStyle = !verbatim;
this->Makefile->AddUtilityCommand(args[0].c_str(), all,
working_directory.c_str(), depends,
- commandLines, escapeOldStyle);
+ commandLines, escapeOldStyle, comment);
return true;
}
diff --git a/Source/cmAddCustomTargetCommand.h b/Source/cmAddCustomTargetCommand.h
index a8ed7c4..b8808b8 100644
--- a/Source/cmAddCustomTargetCommand.h
+++ b/Source/cmAddCustomTargetCommand.h
@@ -66,7 +66,8 @@ public:
" ADD_CUSTOM_TARGET(Name [ALL] [command1 [args1...]]\n"
" [COMMAND command2 [args2...] ...]\n"
" [DEPENDS depend depend depend ... ]\n"
- " [WORKING_DIRECTORY dir] [VERBATIM])\n"
+ " [WORKING_DIRECTORY dir]\n"
+ " [COMMENT comment] [VERBATIM])\n"
"Adds a target with the given name that executes the given commands. "
"The target has no output file and is ALWAYS CONSIDERED OUT OF DATE "
"even if the commands try to create a file with the name of the "
@@ -81,6 +82,8 @@ public:
"empty target will be created. "
"If WORKING_DIRECTORY is set, then the command will be run in that "
"directory. "
+ "If COMMENT is set, the value will be displayed as a "
+ "message before the commands are executed at build time. "
"Dependencies listed with the DEPENDS argument may reference files "
"and outputs of custom commands created with ADD_CUSTOM_COMMAND.\n"
"If VERBATIM is given then all the arguments to the commands will be "
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 52a9127..226f5d5 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -823,7 +823,7 @@ void cmMakefile::AddUtilityCommand(const char* utilityName, bool all,
const char* workingDirectory,
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines,
- bool escapeOldStyle)
+ bool escapeOldStyle, const char* comment)
{
// Create a target instance for this utility.
cmTarget target;
@@ -831,17 +831,22 @@ void cmMakefile::AddUtilityCommand(const char* utilityName, bool all,
target.SetInAll(all);
target.SetMakefile(this);
+ if(!comment)
+ {
+ // Use an empty comment to avoid generation of default comment.
+ comment = "";
+ }
+
// Store the custom command in the target.
std::string force = this->GetStartOutputDirectory();
force += cmake::GetCMakeFilesDirectory();
force += "/";
force += utilityName;
const char* no_main_dependency = 0;
- const char* empty_comment = "";
bool no_replace = false;
this->AddCustomCommandToOutput(force.c_str(), depends,
no_main_dependency,
- commandLines, empty_comment,
+ commandLines, comment,
workingDirectory, no_replace,
escapeOldStyle);
target.GetSourceLists().push_back(force);
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 094fee9..942858e 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -195,7 +195,8 @@ public:
const char* workingDirectory,
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines,
- bool escapeOldStyle = true);
+ bool escapeOldStyle = true,
+ const char* comment = 0);
/**
* Add a link library to the build.