cmExecProgramCommand.cxx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 "cmExecProgramCommand.h"
  14. #include "cmSystemTools.h"
  15. // cmExecProgramCommand
  16. bool cmExecProgramCommand::InitialPass(std::vector<std::string> const& argsIn)
  17. {
  18. std::vector<std::string> args = argsIn;
  19. if(args.size() < 1 )
  20. {
  21. this->SetError("called with incorrect number of arguments");
  22. return false;
  23. }
  24. std::string output;
  25. m_Makefile->ExpandVariablesInString(args[0]);
  26. if(args.size() == 2)
  27. {
  28. m_Makefile->ExpandVariablesInString(args[1]);
  29. cmSystemTools::MakeDirectory(args[1].c_str());
  30. std::string command;
  31. command = "cd ";
  32. command += args[1].c_str();
  33. command += " && ";
  34. command += args[0].c_str();
  35. cmSystemTools::RunCommand(command.c_str(), output);
  36. }
  37. else
  38. {
  39. cmSystemTools::RunCommand(args[0].c_str(), output);
  40. }
  41. return true;
  42. }