cmAddDependenciesCommand.cxx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Insight Consortium. All rights reserved.
  8. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm 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 "cmCacheManager.h"
  15. // cmDependenciesCommand
  16. bool cmAddDependenciesCommand::InitialPass(std::vector<std::string> const& args)
  17. {
  18. if(args.size() < 2 )
  19. {
  20. this->SetError("called with incorrect number of arguments");
  21. return false;
  22. }
  23. std::string target_name = args[0];
  24. m_Makefile->ExpandVariablesInString(target_name);
  25. cmTargets &tgts = m_Makefile->GetTargets();
  26. if (tgts.find(target_name) != tgts.end())
  27. {
  28. std::vector<std::string>::const_iterator s = args.begin();
  29. ++s;
  30. std::string depend_target;
  31. for (; s != args.end(); ++s)
  32. {
  33. depend_target = *s;
  34. m_Makefile->ExpandVariablesInString(depend_target);
  35. tgts[target_name].AddUtility(depend_target.c_str());
  36. }
  37. }
  38. else
  39. {
  40. std::cerr << "existing targets are:";
  41. for(cmTargets::iterator i = tgts.begin();
  42. i != tgts.end(); ++i)
  43. {
  44. std::cerr << i->first << std::endl;
  45. }
  46. std::string error = "Adding dependency to non-existent target: ";
  47. error += target_name;
  48. this->SetError(error.c_str());
  49. return false;
  50. }
  51. return true;
  52. }