Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / cmSetTargetPropertiesCommand.cxx
blobd3a8ab27ad678599573fb7e5a7b9c3207a231b93
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmSetTargetPropertiesCommand.cxx,v $
5 Language: C++
6 <<<<<<< cmSetTargetPropertiesCommand.cxx
7 Date: $Date: 2008/01/28 13:38:36 $
8 Version: $Revision: 1.9 $
9 =======
10 Date: $Date: 2008-08-19 15:43:51 $
11 Version: $Revision: 1.10 $
12 >>>>>>> 1.10
14 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
15 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
17 This software is distributed WITHOUT ANY WARRANTY; without even
18 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
19 PURPOSE. See the above copyright notices for more information.
21 =========================================================================*/
22 #include "cmSetTargetPropertiesCommand.h"
23 #include "cmLocalGenerator.h"
24 #include "cmGlobalGenerator.h"
26 // cmSetTargetPropertiesCommand
27 bool cmSetTargetPropertiesCommand
28 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
30 if(args.size() < 2 )
32 this->SetError("called with incorrect number of arguments");
33 return false;
36 // first collect up the list of files
37 std::vector<std::string> propertyPairs;
38 bool doingFiles = true;
39 int numFiles = 0;
40 std::vector<std::string>::const_iterator j;
41 for(j= args.begin(); j != args.end();++j)
43 if(*j == "PROPERTIES")
45 doingFiles = false;
46 // now loop through the rest of the arguments, new style
47 ++j;
48 while (j != args.end())
50 propertyPairs.push_back(*j);
51 ++j;
52 if(j == args.end())
54 this->SetError("called with incorrect number of arguments.");
55 return false;
57 propertyPairs.push_back(*j);
58 ++j;
60 // break out of the loop because j is already == end
61 break;
63 else if (doingFiles)
65 numFiles++;
67 else
69 this->SetError("called with illegal arguments, maybe missing "
70 "a PROPERTIES specifier?");
71 return false;
74 if(propertyPairs.size() == 0)
76 this->SetError("called with illegal arguments, maybe missing "
77 "a PROPERTIES specifier?");
78 return false;
81 // now loop over all the targets
82 int i;
83 for(i = 0; i < numFiles; ++i)
85 bool ret = cmSetTargetPropertiesCommand::SetOneTarget
86 (args[i].c_str(),propertyPairs,this->Makefile);
87 if (!ret)
89 std::string message = "Can not find target to add properties to: ";
90 message += args[i];
91 this->SetError(message.c_str());
92 return false;
95 return true;
98 bool cmSetTargetPropertiesCommand
99 ::SetOneTarget(const char *tname,
100 std::vector<std::string> &propertyPairs,
101 cmMakefile *mf)
103 if(cmTarget* target = mf->FindTargetToUse(tname))
105 // now loop through all the props and set them
106 unsigned int k;
107 for (k = 0; k < propertyPairs.size(); k = k + 2)
109 target->SetProperty(propertyPairs[k].c_str(),
110 propertyPairs[k+1].c_str());
111 target->CheckProperty(propertyPairs[k].c_str(), mf);
114 // if file is not already in the makefile, then add it
115 else
117 return false;
119 return true;