cmAddCustomTargetCommand.cxx 1.7 KB

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