cmAddCustomTargetCommand.cxx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 "cmAddCustomTargetCommand.h"
  14. // cmAddCustomTargetCommand
  15. bool cmAddCustomTargetCommand::InitialPass(std::vector<std::string> const& args)
  16. {
  17. bool all = false;
  18. if(args.size() < 2 )
  19. {
  20. this->SetError("called with incorrect number of arguments");
  21. return false;
  22. }
  23. // all target option
  24. std::string arguments;
  25. std::vector<std::string>::const_iterator s = args.begin();
  26. ++s; // move past args[0] as it is already to be used
  27. if (args.size() >= 2)
  28. {
  29. if (args[1] == "ALL")
  30. {
  31. all = true;
  32. ++s; // skip all
  33. }
  34. }
  35. std::string command;
  36. if(s != args.end())
  37. {
  38. command = *s;
  39. ++s;
  40. }
  41. for (;s != args.end() && *s != "DEPENDS"; ++s)
  42. {
  43. arguments += cmSystemTools::EscapeSpaces(s->c_str());
  44. arguments += " ";
  45. }
  46. std::vector<std::string> depends;
  47. // skip depends keyword
  48. if (s != args.end())
  49. {
  50. ++s;
  51. }
  52. while (s != args.end())
  53. {
  54. depends.push_back(*s);
  55. ++s;
  56. }
  57. m_Makefile->AddUtilityCommand(args[0].c_str(),
  58. command.c_str(),
  59. arguments.c_str(), all, depends);
  60. return true;
  61. }