cmGetTargetPropertyCommand.cxx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmGetTargetPropertyCommand.h"
  11. // cmSetTargetPropertyCommand
  12. bool cmGetTargetPropertyCommand
  13. ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
  14. {
  15. if(args.size() != 3 )
  16. {
  17. this->SetError("called with incorrect number of arguments");
  18. return false;
  19. }
  20. std::string var = args[0].c_str();
  21. const char* targetName = args[1].c_str();
  22. const char *prop = 0;
  23. if(args[2] == "ALIASED_TARGET")
  24. {
  25. if(this->Makefile->IsAlias(targetName))
  26. {
  27. if(cmTarget* target =
  28. this->Makefile->FindTargetToUse(targetName))
  29. {
  30. prop = target->GetName();
  31. }
  32. }
  33. }
  34. else if(cmTarget* tgt = this->Makefile->FindTargetToUse(targetName))
  35. {
  36. cmTarget& target = *tgt;
  37. prop = target.GetProperty(args[2].c_str());
  38. }
  39. if (prop)
  40. {
  41. this->Makefile->AddDefinition(var.c_str(), prop);
  42. return true;
  43. }
  44. this->Makefile->AddDefinition(var.c_str(), (var+"-NOTFOUND").c_str());
  45. return true;
  46. }