cmSourceFilesRemoveCommand.cxx 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 "cmSourceFilesRemoveCommand.h"
  14. // cmSourceFilesRemoveCommand
  15. bool cmSourceFilesRemoveCommand::InitialPass(std::vector<std::string> const& argsIn)
  16. {
  17. if(argsIn.size() < 1 )
  18. {
  19. this->SetError("called with incorrect number of arguments");
  20. return false;
  21. }
  22. std::vector<std::string> args;
  23. cmSystemTools::ExpandListArguments(argsIn, args);
  24. int generated = 0;
  25. for(std::vector<std::string>::const_iterator i = (args.begin() + 1);
  26. i != args.end(); ++i)
  27. {
  28. std::string copy = *i;
  29. if ( copy == "GENERATED" )
  30. {
  31. generated = 1;
  32. continue;
  33. }
  34. cmSourceFile file;
  35. if ( generated )
  36. {
  37. // This file will be generated, so we should not check
  38. // if it exist.
  39. std::string ext = cmSystemTools::GetFilenameExtension(copy);
  40. std::string path = cmSystemTools::GetFilenamePath(copy);
  41. std::string name_no_ext = cmSystemTools::GetFilenameName(copy.c_str());
  42. name_no_ext = name_no_ext.substr(0, name_no_ext.length()-ext.length());
  43. if ( ext.length() && ext[0] == '.' )
  44. {
  45. ext = ext.substr(1);
  46. }
  47. if((path.size() && path[0] == '/') ||
  48. (path.size() > 1 && path[1] == ':'))
  49. {
  50. file.SetName(name_no_ext.c_str(), path.c_str(), ext.c_str(), false);
  51. }
  52. else
  53. {
  54. file.SetName(name_no_ext.c_str(), m_Makefile->GetCurrentOutputDirectory(),
  55. ext.c_str(), false);
  56. }
  57. }
  58. else
  59. {
  60. file.SetName((*i).c_str(), m_Makefile->GetCurrentDirectory(),
  61. m_Makefile->GetSourceExtensions(),
  62. m_Makefile->GetHeaderExtensions());
  63. }
  64. m_Makefile->RemoveSource(file, args[0].c_str());
  65. }
  66. return true;
  67. }