cmWrapExcludeFilesCommand.cxx 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 "cmWrapExcludeFilesCommand.h"
  14. // cmWrapExcludeFilesCommand
  15. bool cmWrapExcludeFilesCommand::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 WRAP_EXCLUDE_FILES command has been deprecated in CMake version 1.4. You should use the SET_SOURCE_FILES_PROPERTIES 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. m_Makefile->ExpandSourceListArguments(argsIn, args, 0);
  31. for(std::vector<std::string>::const_iterator j = args.begin();
  32. j != args.end(); ++j)
  33. {
  34. // if the file is already in the makefile just set properites on it
  35. cmSourceFile* sf = m_Makefile->GetSource(j->c_str());
  36. if(sf)
  37. {
  38. sf->SetWrapExclude(true);
  39. }
  40. // if file is not already in the makefile, then add it
  41. else
  42. {
  43. std::string newfile = *j;
  44. cmSourceFile file;
  45. std::string path = cmSystemTools::GetFilenamePath(newfile);
  46. // set the flags
  47. file.SetWrapExclude(true);
  48. // if this is a full path then
  49. if((path.size() && path[0] == '/') ||
  50. (path.size() > 1 && path[1] == ':'))
  51. {
  52. file.SetName(cmSystemTools::GetFilenameName(newfile.c_str()).c_str(),
  53. path.c_str(),
  54. m_Makefile->GetSourceExtensions(),
  55. m_Makefile->GetHeaderExtensions());
  56. }
  57. else
  58. {
  59. file.SetName(newfile.c_str(), m_Makefile->GetCurrentDirectory(),
  60. m_Makefile->GetSourceExtensions(),
  61. m_Makefile->GetHeaderExtensions());
  62. }
  63. // add the source file to the makefile
  64. m_Makefile->AddSource(file);
  65. }
  66. }
  67. return true;
  68. }