packaging: Initial packaging
[platform/upstream/cmake.git] / Source / cmGetTargetPropertyCommand.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 "cmGetTargetPropertyCommand.h"
13
14 // cmSetTargetPropertyCommand
15 bool cmGetTargetPropertyCommand
16 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
17 {
18   if(args.size() != 3 )
19     {
20     this->SetError("called with incorrect number of arguments");
21     return false;
22     }
23   std::string var = args[0].c_str();
24   const char* targetName = args[1].c_str();
25   const char *prop = 0;
26
27   if(args[2] == "ALIASED_TARGET")
28     {
29     if(this->Makefile->IsAlias(targetName))
30       {
31       if(cmTarget* target =
32                           this->Makefile->FindTargetToUse(targetName))
33         {
34         prop = target->GetName();
35         }
36       }
37     }
38   else if(cmTarget* tgt = this->Makefile->FindTargetToUse(targetName))
39     {
40     cmTarget& target = *tgt;
41     prop = target.GetProperty(args[2].c_str());
42     }
43
44   if (prop)
45     {
46     this->Makefile->AddDefinition(var.c_str(), prop);
47     return true;
48     }
49   this->Makefile->AddDefinition(var.c_str(), (var+"-NOTFOUND").c_str());
50   return true;
51 }
52