summaryrefslogtreecommitdiffstats
path: root/Source/cmAddCustomTargetCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-10-09 15:01:23 (GMT)
committerBrad King <brad.king@kitware.com>2008-10-09 15:01:23 (GMT)
commitc5f70ff27fb7ea9d2421b4cc25e303f171612525 (patch)
tree37012c7d62a1d729b70437e867a4fe3f83c6dc7d /Source/cmAddCustomTargetCommand.cxx
parent0ad5eb177b4b1f56c1ae29445575dc63d4ddf0eb (diff)
downloadCMake-c5f70ff27fb7ea9d2421b4cc25e303f171612525.zip
CMake-c5f70ff27fb7ea9d2421b4cc25e303f171612525.tar.gz
CMake-c5f70ff27fb7ea9d2421b4cc25e303f171612525.tar.bz2
ENH: Allow custom sources in custom targets
This adds a SOURCES option to ADD_CUSTOM_TARGET, enabling users to specify extra sources for inclusion in the target. Such sources may not build, but will show up in the IDE project files for convenient editing. See issue #5848.
Diffstat (limited to 'Source/cmAddCustomTargetCommand.cxx')
-rw-r--r--Source/cmAddCustomTargetCommand.cxx19
1 files changed, 16 insertions, 3 deletions
diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx
index 94854b1..b609bd2 100644
--- a/Source/cmAddCustomTargetCommand.cxx
+++ b/Source/cmAddCustomTargetCommand.cxx
@@ -55,6 +55,7 @@ bool cmAddCustomTargetCommand
bool verbatim = false;
std::string comment_buffer;
const char* comment = 0;
+ std::vector<std::string> sources;
// Keep track of parser state.
enum tdoing {
@@ -62,6 +63,7 @@ bool cmAddCustomTargetCommand
doing_depends,
doing_working_directory,
doing_comment,
+ doing_source,
doing_verbatim
};
tdoing doing = doing_command;
@@ -111,6 +113,10 @@ bool cmAddCustomTargetCommand
currentLine.clear();
}
}
+ else if(copy == "SOURCES")
+ {
+ doing = doing_source;
+ }
else
{
switch (doing)
@@ -128,6 +134,9 @@ bool cmAddCustomTargetCommand
comment_buffer = copy;
comment = comment_buffer.c_str();
break;
+ case doing_source:
+ sources.push_back(copy);
+ break;
default:
this->SetError("Wrong syntax. Unknown type of argument.");
return false;
@@ -164,9 +173,13 @@ bool cmAddCustomTargetCommand
// Add the utility target to the makefile.
bool escapeOldStyle = !verbatim;
- this->Makefile->AddUtilityCommand(args[0].c_str(), excludeFromAll,
- working_directory.c_str(), depends,
- commandLines, escapeOldStyle, comment);
+ cmTarget* target =
+ this->Makefile->AddUtilityCommand(args[0].c_str(), excludeFromAll,
+ working_directory.c_str(), depends,
+ commandLines, escapeOldStyle, comment);
+
+ // Add additional user-specified source files to the target.
+ target->AddSources(sources);
return true;
}