diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2005-07-13 15:21:30 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2005-07-13 15:21:30 (GMT) |
commit | aa47caab2db3961bfdd53036e5637df208b319d4 (patch) | |
tree | 1bd23995ec567a67fe8cccadd3750a215ea48829 /Source/cmSourceGroupCommand.cxx | |
parent | 1e72091e8631f1a94262a1a10b58d6b0a975db01 (diff) | |
download | CMake-aa47caab2db3961bfdd53036e5637df208b319d4.zip CMake-aa47caab2db3961bfdd53036e5637df208b319d4.tar.gz CMake-aa47caab2db3961bfdd53036e5637df208b319d4.tar.bz2 |
FIX: apply patch from bug# 1965
Diffstat (limited to 'Source/cmSourceGroupCommand.cxx')
-rw-r--r-- | Source/cmSourceGroupCommand.cxx | 74 |
1 files changed, 66 insertions, 8 deletions
diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx index 131e86c..01b969f 100644 --- a/Source/cmSourceGroupCommand.cxx +++ b/Source/cmSourceGroupCommand.cxx @@ -16,6 +16,50 @@ =========================================================================*/ #include "cmSourceGroupCommand.h" +inline std::vector<std::string> tokenize(const std::string& str, + const std::string& sep, + bool skipEmptyTokens) +{ + std::vector<std::string> tokens; + std::string::size_type tokstart,tokend; + + if (skipEmptyTokens) + { + tokend=0; + } + else + { + tokend=std::string::npos; + } + + do + { + if (skipEmptyTokens) + { + tokstart=str.find_first_not_of(sep,tokend); + } + else + { + tokstart=tokend+1; + } + if (tokstart==std::string::npos) + { + break; // no more tokens + } + tokend=str.find_first_of(sep,tokstart); + if (tokend==std::string::npos) + { + tokens.push_back(str.substr(tokstart)); + } + else + { + tokens.push_back(str.substr(tokstart,tokend-tokstart)); + } + } while (tokend!=std::string::npos); + + return tokens; +} + // cmSourceGroupCommand bool cmSourceGroupCommand::InitialPass(std::vector<std::string> const& args) { @@ -24,18 +68,32 @@ bool cmSourceGroupCommand::InitialPass(std::vector<std::string> const& args) this->SetError("called with incorrect number of arguments"); return false; } - - // Get the source group with the given name. - cmSourceGroup* sg = m_Makefile->GetSourceGroup(args[0].c_str()); - if(!sg) + + std::string delimiter = "\\"; + + if(m_Makefile->GetDefinition("SOURCE_GROUP_DELIMITER")) + delimiter = m_Makefile->GetDefinition("SOURCE_GROUP_DELIMITER"); + + std::vector<std::string> folders = tokenize(args[0], delimiter, true); + + const char *parent = NULL; + + cmSourceGroup* sg = NULL; + + for(unsigned int i=0;i<folders.size();++i) { - m_Makefile->AddSourceGroup(args[0].c_str(), 0); - sg = m_Makefile->GetSourceGroup(args[0].c_str()); + sg = m_Makefile->GetSourceGroup(folders[i].c_str()); + if(!sg) + { + m_Makefile->AddSourceGroup(folders[i].c_str(), 0, parent); + } + sg = m_Makefile->GetSourceGroup(folders[i].c_str()); + parent = folders[i].c_str(); } - + // If only two arguments are given, the pre-1.8 version of the // command is being invoked. - if(args.size() == 2 && args[1] != "FILES") + if(args.size() == 2 && args[1] != "FILES") { sg->SetGroupRegex(args[1].c_str()); return true; |