cmSourceFilesRemoveCommand.cxx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. const char* versionValue
  18. = m_Makefile->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION");
  19. if (versionValue && atof(versionValue) > 1.2)
  20. {
  21. this->SetError("The SOURCE_FILES_REMOVE command has been deprecated in CMake version 1.4. You should use the REMOVE command instead.\n");
  22. return false;
  23. }
  24. if(argsIn.size() < 1 )
  25. {
  26. this->SetError("called with incorrect number of arguments");
  27. return false;
  28. }
  29. std::vector<std::string> args;
  30. cmSystemTools::ExpandListArguments(argsIn, args);
  31. int generated = 0;
  32. for(std::vector<std::string>::const_iterator i = (args.begin() + 1);
  33. i != args.end(); ++i)
  34. {
  35. std::string copy = *i;
  36. if ( copy == "GENERATED" )
  37. {
  38. generated = 1;
  39. continue;
  40. }
  41. cmSourceFile file;
  42. if ( generated )
  43. {
  44. // This file will be generated, so we should not check
  45. // if it exist.
  46. std::string ext = cmSystemTools::GetFilenameExtension(copy);
  47. std::string path = cmSystemTools::GetFilenamePath(copy);
  48. std::string name_no_ext = cmSystemTools::GetFilenameName(copy.c_str());
  49. name_no_ext = name_no_ext.substr(0, name_no_ext.length()-ext.length());
  50. if ( ext.length() && ext[0] == '.' )
  51. {
  52. ext = ext.substr(1);
  53. }
  54. if((path.size() && path[0] == '/') ||
  55. (path.size() > 1 && path[1] == ':'))
  56. {
  57. file.SetName(name_no_ext.c_str(), path.c_str(), ext.c_str(), false);
  58. }
  59. else
  60. {
  61. file.SetName(name_no_ext.c_str(), m_Makefile->GetCurrentOutputDirectory(),
  62. ext.c_str(), false);
  63. }
  64. }
  65. else
  66. {
  67. file.SetName((*i).c_str(), m_Makefile->GetCurrentDirectory(),
  68. m_Makefile->GetSourceExtensions(),
  69. m_Makefile->GetHeaderExtensions());
  70. }
  71. m_Makefile->RemoveSource(file, args[0].c_str());
  72. }
  73. return true;
  74. }