cmWrapExcludeFilesCommand.cxx 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 "cmWrapExcludeFilesCommand.h"
  14. #include <stdlib.h> // required for atof
  15. // cmWrapExcludeFilesCommand
  16. bool cmWrapExcludeFilesCommand::InitialPass(std::vector<std::string> const& argsIn)
  17. {
  18. const char* versionValue
  19. = m_Makefile->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION");
  20. if (versionValue && atof(versionValue) > 1.2)
  21. {
  22. 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");
  23. return false;
  24. }
  25. if(argsIn.size() < 1 )
  26. {
  27. this->SetError("called with incorrect number of arguments");
  28. return false;
  29. }
  30. std::vector<std::string> args;
  31. m_Makefile->ExpandSourceListArguments(argsIn, args, 0);
  32. for(std::vector<std::string>::const_iterator j = args.begin();
  33. j != args.end(); ++j)
  34. {
  35. // if the file is already in the makefile just set properites on it
  36. cmSourceFile* sf = m_Makefile->GetSource(j->c_str());
  37. if(sf)
  38. {
  39. sf->SetProperty("WRAP_EXCLUDE","1");
  40. }
  41. // if file is not already in the makefile, then add it
  42. else
  43. {
  44. std::string newfile = *j;
  45. cmSourceFile file;
  46. std::string path = cmSystemTools::GetFilenamePath(newfile);
  47. // set the flags
  48. file.SetProperty("WRAP_EXCLUDE","1");
  49. // if this is a full path then
  50. if((path.size() && path[0] == '/') ||
  51. (path.size() > 1 && path[1] == ':'))
  52. {
  53. file.SetName(cmSystemTools::GetFilenameName(newfile.c_str()).c_str(),
  54. path.c_str(),
  55. m_Makefile->GetSourceExtensions(),
  56. m_Makefile->GetHeaderExtensions());
  57. }
  58. else
  59. {
  60. file.SetName(newfile.c_str(), m_Makefile->GetCurrentDirectory(),
  61. m_Makefile->GetSourceExtensions(),
  62. m_Makefile->GetHeaderExtensions());
  63. }
  64. // add the source file to the makefile
  65. m_Makefile->AddSource(file);
  66. }
  67. }
  68. return true;
  69. }