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 "cmSetTargetPropertiesCommand.h"
13 #include "cmLocalGenerator.h"
14 #include "cmGlobalGenerator.h"
16 // cmSetTargetPropertiesCommand
17 bool cmSetTargetPropertiesCommand
18 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
22 this->SetError("called with incorrect number of arguments");
26 // first collect up the list of files
27 std::vector<std::string> propertyPairs;
28 bool doingFiles = true;
30 std::vector<std::string>::const_iterator j;
31 for(j= args.begin(); j != args.end();++j)
33 if(*j == "PROPERTIES")
36 // now loop through the rest of the arguments, new style
38 while (j != args.end())
40 propertyPairs.push_back(*j);
44 this->SetError("called with incorrect number of arguments.");
47 propertyPairs.push_back(*j);
50 // break out of the loop because j is already == end
59 this->SetError("called with illegal arguments, maybe missing "
60 "a PROPERTIES specifier?");
64 if(propertyPairs.size() == 0)
66 this->SetError("called with illegal arguments, maybe missing "
67 "a PROPERTIES specifier?");
71 // now loop over all the targets
73 for(i = 0; i < numFiles; ++i)
75 if (this->Makefile->IsAlias(args[i].c_str()))
77 this->SetError("can not be used on an ALIAS target.");
80 bool ret = cmSetTargetPropertiesCommand::SetOneTarget
81 (args[i].c_str(),propertyPairs,this->Makefile);
84 std::string message = "Can not find target to add properties to: ";
86 this->SetError(message.c_str());
93 bool cmSetTargetPropertiesCommand
94 ::SetOneTarget(const char *tname,
95 std::vector<std::string> &propertyPairs,
98 if(cmTarget* target = mf->FindTargetToUse(tname))
100 // now loop through all the props and set them
102 for (k = 0; k < propertyPairs.size(); k = k + 2)
104 target->SetProperty(propertyPairs[k].c_str(),
105 propertyPairs[k+1].c_str());
106 target->CheckProperty(propertyPairs[k].c_str(), mf);
109 // if file is not already in the makefile, then add it