Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / cmSetTargetPropertiesCommand.cxx
blob185ff234d55abc4751ab6916766e9575b31ca0e2
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmSetTargetPropertiesCommand.cxx,v $
5 Language: C++
6 Date: $Date: 2008/01/28 13:38:36 $
7 Version: $Revision: 1.9 $
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 "cmSetTargetPropertiesCommand.h"
18 #include "cmLocalGenerator.h"
19 #include "cmGlobalGenerator.h"
21 // cmSetTargetPropertiesCommand
22 bool cmSetTargetPropertiesCommand
23 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
25 if(args.size() < 2 )
27 this->SetError("called with incorrect number of arguments");
28 return false;
31 // first collect up the list of files
32 std::vector<std::string> propertyPairs;
33 bool doingFiles = true;
34 int numFiles = 0;
35 std::vector<std::string>::const_iterator j;
36 for(j= args.begin(); j != args.end();++j)
38 if(*j == "PROPERTIES")
40 doingFiles = false;
41 // now loop through the rest of the arguments, new style
42 ++j;
43 while (j != args.end())
45 propertyPairs.push_back(*j);
46 ++j;
47 if(j == args.end())
49 this->SetError("called with incorrect number of arguments.");
50 return false;
52 propertyPairs.push_back(*j);
53 ++j;
55 // break out of the loop because j is already == end
56 break;
58 else if (doingFiles)
60 numFiles++;
62 else
64 this->SetError("called with illegal arguments, maybe missing "
65 "a PROPERTIES specifier?");
66 return false;
69 if(propertyPairs.size() == 0)
71 this->SetError("called with illegal arguments, maybe missing "
72 "a PROPERTIES specifier?");
73 return false;
76 // now loop over all the targets
77 int i;
78 for(i = 0; i < numFiles; ++i)
80 bool ret = cmSetTargetPropertiesCommand::SetOneTarget
81 (args[i].c_str(),propertyPairs,this->Makefile);
82 if (!ret)
84 std::string message = "Can not find target to add properties to: ";
85 message += args[i];
86 this->SetError(message.c_str());
87 return false;
90 return true;
93 bool cmSetTargetPropertiesCommand
94 ::SetOneTarget(const char *tname,
95 std::vector<std::string> &propertyPairs,
96 cmMakefile *mf)
98 if(cmTarget* target = mf->FindTargetToUse(tname))
100 // now loop through all the props and set them
101 unsigned int k;
102 for (k = 0; k < propertyPairs.size(); k = k + 2)
104 target->SetProperty(propertyPairs[k].c_str(),
105 propertyPairs[k+1].c_str());
108 // if file is not already in the makefile, then add it
109 else
111 return false;
113 return true;