Imported Upstream version 2.8.9
[platform/upstream/cmake.git] / Source / cmAddDependenciesCommand.cxx
1 /*============================================================================
2   CMake - Cross Platform Makefile Generator
3   Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
4
5   Distributed under the OSI-approved BSD License (the "License");
6   see accompanying file Copyright.txt for details.
7
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 "cmAddDependenciesCommand.h"
13 #include "cmLocalGenerator.h"
14 #include "cmGlobalGenerator.h"
15
16 // cmDependenciesCommand
17 bool cmAddDependenciesCommand
18 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
19 {
20   if(args.size() < 2 )
21     {
22     this->SetError("called with incorrect number of arguments");
23     return false;
24     }
25
26   std::string target_name = args[0];
27   if(cmTarget* target = this->Makefile->FindTargetToUse(target_name.c_str()))
28     {
29     std::vector<std::string>::const_iterator s = args.begin();
30     ++s; // skip over target_name
31     for (; s != args.end(); ++s)
32       {
33       target->AddUtility(s->c_str());
34       }
35     }
36   else
37     {
38     std::string error = "Adding dependency to non-existent target: ";
39     error += target_name;
40     this->SetError(error.c_str());
41     return false;
42     }
43
44   return true;
45 }
46