cmSourceFilesRemoveCommand.cxx 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 "cmSourceFilesRemoveCommand.h"
  14. // cmSourceFilesRemoveCommand
  15. bool cmSourceFilesRemoveCommand::InitialPass(std::vector<std::string> const& args)
  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(args.size() < 2 )
  25. {
  26. this->SetError("called with incorrect number of arguments");
  27. return false;
  28. }
  29. const char* variable = args[0].c_str(); // VAR is always first
  30. // get the old value
  31. const char* cacheValue
  32. = m_Makefile->GetDefinition(variable);
  33. // expand the variable
  34. std::vector<std::string> varArgsExpanded;
  35. cmSystemTools::ExpandListArgument(cacheValue, varArgsExpanded);
  36. // expand the args
  37. // check for REMOVE(VAR v1 v2 ... vn)
  38. std::vector<std::string> argsExpanded;
  39. std::vector<std::string> temp;
  40. for(unsigned int j = 1; j < args.size(); ++j)
  41. {
  42. temp.push_back(args[j]);
  43. }
  44. cmSystemTools::ExpandList(temp, argsExpanded);
  45. // now create the new value
  46. std::string value;
  47. for(unsigned int j = 0; j < varArgsExpanded.size(); ++j)
  48. {
  49. int found = 0;
  50. for(unsigned int k = 0; k < argsExpanded.size(); ++k)
  51. {
  52. if (varArgsExpanded[j] == argsExpanded[k])
  53. {
  54. found = 1;
  55. break;
  56. }
  57. }
  58. if (!found)
  59. {
  60. if (value.size())
  61. {
  62. value += ";";
  63. }
  64. value += varArgsExpanded[j];
  65. }
  66. }
  67. // add the definition
  68. m_Makefile->AddDefinition(variable, value.c_str());
  69. return true;
  70. }