cmSetSourceFilesPropertiesCommand.cxx 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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 "cmSetSourceFilesPropertiesCommand.h"
  14. // cmSetSourceFilesPropertiesCommand
  15. bool cmSetSourceFilesPropertiesCommand::InitialPass(
  16. std::vector<std::string> const& args)
  17. {
  18. if(args.size() < 2 )
  19. {
  20. this->SetError("called with incorrect number of arguments");
  21. return false;
  22. }
  23. // first collect up the list of files
  24. std::vector<std::string> propertyPairs;
  25. bool doingFiles = true;
  26. bool generated = false;
  27. int numFiles = 0;
  28. std::vector<std::string>::const_iterator j;
  29. for(j= args.begin(); j != args.end();++j)
  30. {
  31. // old style allows for specifier before PROPERTIES keyword
  32. if(*j == "ABSTRACT")
  33. {
  34. doingFiles = false;
  35. propertyPairs.push_back("ABSTRACT");
  36. propertyPairs.push_back("1");
  37. }
  38. else if(*j == "WRAP_EXCLUDE")
  39. {
  40. doingFiles = false;
  41. propertyPairs.push_back("WRAP_EXCLUDE");
  42. propertyPairs.push_back("1");
  43. }
  44. else if(*j == "GENERATED")
  45. {
  46. doingFiles = false;
  47. generated = true;
  48. propertyPairs.push_back("GENERATED");
  49. propertyPairs.push_back("1");
  50. }
  51. else if(*j == "COMPILE_FLAGS")
  52. {
  53. doingFiles = false;
  54. propertyPairs.push_back("COMPILE_FLAGS");
  55. ++j;
  56. if(j == args.end())
  57. {
  58. this->SetError("called with incorrect number of arguments COMPILE_FLAGS with no flags");
  59. return false;
  60. }
  61. propertyPairs.push_back(*j);
  62. }
  63. else if(*j == "OBJECT_DEPENDS")
  64. {
  65. doingFiles = false;
  66. propertyPairs.push_back("OBJECT_DEPENDS");
  67. ++j;
  68. if(j == args.end())
  69. {
  70. this->SetError("called with incorrect number of arguments "
  71. "OBJECT_DEPENDS with no dependencies");
  72. return false;
  73. }
  74. propertyPairs.push_back(*j);
  75. }
  76. else if(*j == "PROPERTIES")
  77. {
  78. // now loop through the rest of the arguments, new style
  79. ++j;
  80. while (j != args.end())
  81. {
  82. propertyPairs.push_back(*j);
  83. if(*j == "GENERATED")
  84. {
  85. ++j;
  86. if(j != args.end() && cmSystemTools::IsOn(j->c_str()))
  87. {
  88. generated = true;
  89. }
  90. }
  91. else
  92. {
  93. ++j;
  94. }
  95. if(j == args.end())
  96. {
  97. this->SetError("called with incorrect number of arguments.");
  98. return false;
  99. }
  100. propertyPairs.push_back(*j);
  101. ++j;
  102. }
  103. // break out of the loop because j is already == end
  104. break;
  105. }
  106. else if (doingFiles)
  107. {
  108. numFiles++;
  109. }
  110. else
  111. {
  112. this->SetError("called with illegal arguments, maybe missing a PROPERTIES specifier?");
  113. return false;
  114. }
  115. }
  116. // now loop over all the files
  117. int i;
  118. unsigned int k;
  119. for(i = 0; i < numFiles; ++i)
  120. {
  121. // get the source file
  122. cmSourceFile* sf =
  123. m_Makefile->GetOrCreateSource(args[i].c_str(), generated);
  124. // now loop through all the props and set them
  125. for (k = 0; k < propertyPairs.size(); k = k + 2)
  126. {
  127. sf->SetProperty(propertyPairs[k].c_str(),propertyPairs[k+1].c_str());
  128. }
  129. }
  130. return true;
  131. }