summaryrefslogtreecommitdiffstats
path: root/Source/cmSourceGroupCommand.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmSourceGroupCommand.cxx')
-rw-r--r--Source/cmSourceGroupCommand.cxx71
1 files changed, 47 insertions, 24 deletions
diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx
index 2978aed..621b564 100644
--- a/Source/cmSourceGroupCommand.cxx
+++ b/Source/cmSourceGroupCommand.cxx
@@ -24,37 +24,60 @@ bool cmSourceGroupCommand::InitialPass(std::vector<std::string> const& args)
this->SetError("called with incorrect number of arguments");
return false;
}
-
- if ( args[1] == "REGULAR_EXPRESSION" && args.size() == 3 )
+
+ // Get the source group with the given name.
+ cmSourceGroup* sg = m_Makefile->GetSourceGroup(args[0].c_str());
+ if(!sg)
{
- m_Makefile->AddSourceGroup(args[0].c_str(), args[2].c_str());
- return true;
+ m_Makefile->AddSourceGroup(args[0].c_str(), 0);
+ sg = m_Makefile->GetSourceGroup(args[0].c_str());
}
-
- if ( args[1] == "FILES" )
+
+ // Process arguments.
+ bool doingFiles = false;
+ for(unsigned int i=1; i < args.size(); ++i)
{
- cmSourceGroup* sg = m_Makefile->GetSourceGroup(args[0].c_str());
- if ( !sg )
+ if(args[i] == "REGULAR_EXPRESSION")
+ {
+ // Next argument must specify the regex.
+ if(i+1 < args.size())
+ {
+ ++i;
+ sg->SetGroupRegex(args[i].c_str());
+ }
+ else
+ {
+ this->SetError("REGULAR_EXPRESSION argument given without a regex.");
+ return false;
+ }
+ doingFiles = false;
+ }
+ else if(args[i] == "FILES")
{
- m_Makefile->AddSourceGroup(args[0].c_str(), 0);
- sg = m_Makefile->GetSourceGroup(args[0].c_str());
+ // Next arguments will specify files.
+ doingFiles = true;
}
- unsigned int cc;
- for ( cc = 2; cc < args.size(); cc ++ )
+ else if(doingFiles)
{
- sg->AddSource(args[cc].c_str(), 0);
+ // Convert name to full path and add to the group's list.
+ std::string src = args[i].c_str();
+ if(!cmSystemTools::FileIsFullPath(src.c_str()))
+ {
+ src = m_Makefile->GetCurrentDirectory();
+ src += "/";
+ src += args[i];
+ }
+ sg->AddGroupFile(src.c_str());
+ }
+ else
+ {
+ cmOStringStream err;
+ err << "Unknown argument \"" << args[i].c_str() << "\". "
+ << "Perhaps the FILES keyword is missing.\n";
+ this->SetError(err.str().c_str());
+ return false;
}
-
- return true;
}
- if ( args.size() == 2 )
- {
- m_Makefile->AddSourceGroup(args[0].c_str(), args[1].c_str());
- return true;
- }
-
- this->SetError("called with incorrect number of arguments");
- return false;
+ return true;
}
-