1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
5 Distributed under the OSI-approved BSD License (the "License");
6 see accompanying file Copyright.txt for details.
8 This software is distributed WITHOUT ANY WARRANTY; without even the
9 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License for more information.
11 ============================================================================*/
12 #include "cmSourceGroupCommand.h"
14 // cmSourceGroupCommand
15 bool cmSourceGroupCommand
16 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
20 this->SetError("called with incorrect number of arguments");
24 std::string delimiter = "\\";
25 if(this->Makefile->GetDefinition("SOURCE_GROUP_DELIMITER"))
27 delimiter = this->Makefile->GetDefinition("SOURCE_GROUP_DELIMITER");
30 std::vector<std::string> folders =
31 cmSystemTools::tokenize(args[0], delimiter);
33 cmSourceGroup* sg = 0;
34 sg = this->Makefile->GetSourceGroup(folders);
37 this->Makefile->AddSourceGroup(folders);
38 sg = this->Makefile->GetSourceGroup(folders);
43 this->SetError("Could not create or find source group");
46 // If only two arguments are given, the pre-1.8 version of the
47 // command is being invoked.
48 if(args.size() == 2 && args[1] != "FILES")
50 sg->SetGroupRegex(args[1].c_str());
55 bool doingFiles = false;
56 for(unsigned int i=1; i < args.size(); ++i)
58 if(args[i] == "REGULAR_EXPRESSION")
60 // Next argument must specify the regex.
64 sg->SetGroupRegex(args[i].c_str());
68 this->SetError("REGULAR_EXPRESSION argument given without a regex.");
73 else if(args[i] == "FILES")
75 // Next arguments will specify files.
80 // Convert name to full path and add to the group's list.
81 std::string src = args[i].c_str();
82 if(!cmSystemTools::FileIsFullPath(src.c_str()))
84 src = this->Makefile->GetCurrentDirectory();
88 src = cmSystemTools::CollapseFullPath(src.c_str());
89 sg->AddGroupFile(src.c_str());
94 err << "Unknown argument \"" << args[i].c_str() << "\". "
95 << "Perhaps the FILES keyword is missing.\n";
96 this->SetError(err.str().c_str());