cmAddDependenciesCommand.cxx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 "cmAddDependenciesCommand.h"
  11. #include "cmLocalGenerator.h"
  12. #include "cmGlobalGenerator.h"
  13. // cmDependenciesCommand
  14. bool cmAddDependenciesCommand
  15. ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
  16. {
  17. if(args.size() < 2 )
  18. {
  19. this->SetError("called with incorrect number of arguments");
  20. return false;
  21. }
  22. std::string target_name = args[0];
  23. cmTarget* target =
  24. this->GetMakefile()->GetLocalGenerator()->
  25. GetGlobalGenerator()->FindTarget(0, target_name.c_str());
  26. if(target)
  27. {
  28. std::vector<std::string>::const_iterator s = args.begin();
  29. ++s; // skip over target_name
  30. for (; s != args.end(); ++s)
  31. {
  32. target->AddUtility(s->c_str());
  33. }
  34. }
  35. else
  36. {
  37. std::string error = "Adding dependency to non-existent target: ";
  38. error += target_name;
  39. this->SetError(error.c_str());
  40. return false;
  41. }
  42. return true;
  43. }