summaryrefslogtreecommitdiffstats
path: root/Source/cmSourceGroupCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2003-07-23 19:32:54 (GMT)
committerBrad King <brad.king@kitware.com>2003-07-23 19:32:54 (GMT)
commit48aedb2ba39621a75065a4b4bc5aca7ea695c65a (patch)
treea0e0608e847a321dd15e681998b2eb0565e74b23 /Source/cmSourceGroupCommand.cxx
parente093bdade050419290a1535ced1ca11fe7f8a2d5 (diff)
downloadCMake-48aedb2ba39621a75065a4b4bc5aca7ea695c65a.zip
CMake-48aedb2ba39621a75065a4b4bc5aca7ea695c65a.tar.gz
CMake-48aedb2ba39621a75065a4b4bc5aca7ea695c65a.tar.bz2
ENH: Fully implemented SOURCE_GROUP command.
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;
}
-