cmAddDependenciesCommand.cxx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #include "cmAddDependenciesCommand.h"
  14. #include "cmLocalGenerator.h"
  15. #include "cmGlobalGenerator.h"
  16. // cmDependenciesCommand
  17. bool cmAddDependenciesCommand
  18. ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
  19. {
  20. if(args.size() < 2 )
  21. {
  22. this->SetError("called with incorrect number of arguments");
  23. return false;
  24. }
  25. std::string target_name = args[0];
  26. cmTarget* target =
  27. this->GetMakefile()->GetLocalGenerator()->
  28. GetGlobalGenerator()->FindTarget(0, target_name.c_str(), false);
  29. if(target)
  30. {
  31. std::vector<std::string>::const_iterator s = args.begin();
  32. ++s; // skip over target_name
  33. for (; s != args.end(); ++s)
  34. {
  35. target->AddUtility(s->c_str());
  36. }
  37. }
  38. else
  39. {
  40. std::string error = "Adding dependency to non-existent target: ";
  41. error += target_name;
  42. this->SetError(error.c_str());
  43. return false;
  44. }
  45. return true;
  46. }