From 035c7fabc3b82cbc9a346c11abe2e9462b4c0379 Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Tue, 30 Oct 2012 15:39:57 -0700 Subject: Imported Upstream version 2.8.9 --- Source/cmSourceGroupCommand.cxx | 102 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 Source/cmSourceGroupCommand.cxx (limited to 'Source/cmSourceGroupCommand.cxx') diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx new file mode 100644 index 000000000..8e61d0a15 --- /dev/null +++ b/Source/cmSourceGroupCommand.cxx @@ -0,0 +1,102 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmSourceGroupCommand.h" + +// cmSourceGroupCommand +bool cmSourceGroupCommand +::InitialPass(std::vector const& args, cmExecutionStatus &) +{ + if(args.size() < 1) + { + this->SetError("called with incorrect number of arguments"); + return false; + } + + std::string delimiter = "\\"; + if(this->Makefile->GetDefinition("SOURCE_GROUP_DELIMITER")) + { + delimiter = this->Makefile->GetDefinition("SOURCE_GROUP_DELIMITER"); + } + + std::vector folders = + cmSystemTools::tokenize(args[0], delimiter); + + cmSourceGroup* sg = 0; + sg = this->Makefile->GetSourceGroup(folders); + if(!sg) + { + this->Makefile->AddSourceGroup(folders); + sg = this->Makefile->GetSourceGroup(folders); + } + + if(!sg) + { + this->SetError("Could not create or find source group"); + return false; + } + // If only two arguments are given, the pre-1.8 version of the + // command is being invoked. + if(args.size() == 2 && args[1] != "FILES") + { + sg->SetGroupRegex(args[1].c_str()); + return true; + } + + // Process arguments. + bool doingFiles = false; + for(unsigned int i=1; i < args.size(); ++i) + { + 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") + { + // Next arguments will specify files. + doingFiles = true; + } + else if(doingFiles) + { + // 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 = this->Makefile->GetCurrentDirectory(); + src += "/"; + src += args[i]; + } + src = cmSystemTools::CollapseFullPath(src.c_str()); + 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; +} -- cgit v1.2.3