Add label summary times to ctest default output. Also, remove parallel time output...
[cmake.git] / Source / cmSourceGroupCommand.cxx
blob031637017e63e6134bc60237834fef870a033083
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmSourceGroupCommand.cxx,v $
5 Language: C++
6 Date: $Date: 2008-01-23 15:27:59 $
7 Version: $Revision: 1.20 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #include "cmSourceGroupCommand.h"
19 inline std::vector<std::string> tokenize(const std::string& str,
20 const std::string& sep)
22 std::vector<std::string> tokens;
23 std::string::size_type tokend = 0;
27 std::string::size_type tokstart=str.find_first_not_of(sep, tokend);
28 if (tokstart==std::string::npos)
30 break; // no more tokens
32 tokend=str.find_first_of(sep,tokstart);
33 if (tokend==std::string::npos)
35 tokens.push_back(str.substr(tokstart));
37 else
39 tokens.push_back(str.substr(tokstart,tokend-tokstart));
41 } while (tokend!=std::string::npos);
43 if (tokens.empty())
45 tokens.push_back("");
47 return tokens;
50 // cmSourceGroupCommand
51 bool cmSourceGroupCommand
52 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
54 if(args.size() < 1)
56 this->SetError("called with incorrect number of arguments");
57 return false;
60 std::string delimiter = "\\";
61 if(this->Makefile->GetDefinition("SOURCE_GROUP_DELIMITER"))
63 delimiter = this->Makefile->GetDefinition("SOURCE_GROUP_DELIMITER");
66 std::vector<std::string> folders = tokenize(args[0], delimiter);
68 cmSourceGroup* sg = 0;
69 sg = this->Makefile->GetSourceGroup(folders);
70 if(!sg)
72 this->Makefile->AddSourceGroup(folders);
73 sg = this->Makefile->GetSourceGroup(folders);
76 if(!sg)
78 this->SetError("Could not create or find source group");
79 return false;
81 // If only two arguments are given, the pre-1.8 version of the
82 // command is being invoked.
83 if(args.size() == 2 && args[1] != "FILES")
85 sg->SetGroupRegex(args[1].c_str());
86 return true;
89 // Process arguments.
90 bool doingFiles = false;
91 for(unsigned int i=1; i < args.size(); ++i)
93 if(args[i] == "REGULAR_EXPRESSION")
95 // Next argument must specify the regex.
96 if(i+1 < args.size())
98 ++i;
99 sg->SetGroupRegex(args[i].c_str());
101 else
103 this->SetError("REGULAR_EXPRESSION argument given without a regex.");
104 return false;
106 doingFiles = false;
108 else if(args[i] == "FILES")
110 // Next arguments will specify files.
111 doingFiles = true;
113 else if(doingFiles)
115 // Convert name to full path and add to the group's list.
116 std::string src = args[i].c_str();
117 if(!cmSystemTools::FileIsFullPath(src.c_str()))
119 src = this->Makefile->GetCurrentDirectory();
120 src += "/";
121 src += args[i];
123 src = cmSystemTools::CollapseFullPath(src.c_str());
124 sg->AddGroupFile(src.c_str());
126 else
128 cmOStringStream err;
129 err << "Unknown argument \"" << args[i].c_str() << "\". "
130 << "Perhaps the FILES keyword is missing.\n";
131 this->SetError(err.str().c_str());
132 return false;
136 return true;