cmGetDirectoryPropertyCommand.cxx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 "cmGetDirectoryPropertyCommand.h"
  14. #include "cmake.h"
  15. // cmGetDirectoryPropertyCommand
  16. bool cmGetDirectoryPropertyCommand::InitialPass(
  17. std::vector<std::string> const& args)
  18. {
  19. if(args.size() < 2 )
  20. {
  21. this->SetError("called with incorrect number of arguments");
  22. return false;
  23. }
  24. std::vector<std::string>::size_type cc;
  25. std::string variable = args[0];
  26. std::string output = "";
  27. if ( args[1] == "VARIABLES" || args[1] == "CACHE_VARIABLES" )
  28. {
  29. int cacheonly = 0;
  30. if ( args[1] == "CACHE_VARIABLES" )
  31. {
  32. cacheonly = 1;
  33. }
  34. std::vector<std::string> vars = m_Makefile->GetDefinitions(cacheonly);
  35. for ( cc = 0; cc < vars.size(); cc ++ )
  36. {
  37. if ( cc > 0 )
  38. {
  39. output += ";";
  40. }
  41. output += vars[cc];
  42. }
  43. }
  44. else if ( args[1] == "MACROS" )
  45. {
  46. m_Makefile->GetListOfMacros(output);
  47. }
  48. else if ( args[1] == "INCLUDE_DIRECTORIES" )
  49. {
  50. std::vector<std::string>::iterator it;
  51. int first = 1;
  52. cmOStringStream str;
  53. for ( it = m_Makefile->GetIncludeDirectories().begin();
  54. it != m_Makefile->GetIncludeDirectories().end();
  55. ++ it )
  56. {
  57. if ( !first )
  58. {
  59. str << ";";
  60. }
  61. str << it->c_str();
  62. first = 0;
  63. }
  64. output = str.str();
  65. }
  66. else if ( args[1] == "INCLUDE_REGULAR_EXPRESSION" )
  67. {
  68. output = m_Makefile->GetIncludeRegularExpression();
  69. }
  70. else if ( args[1] == "LINK_DIRECTORIES" )
  71. {
  72. std::vector<std::string>::iterator it;
  73. int first = 1;
  74. cmOStringStream str;
  75. for ( it = m_Makefile->GetLinkDirectories().begin();
  76. it != m_Makefile->GetLinkDirectories().end();
  77. ++ it )
  78. {
  79. if ( !first )
  80. {
  81. str << ";";
  82. }
  83. str << it->c_str();
  84. first = 0;
  85. }
  86. output = str.str();
  87. }
  88. else
  89. {
  90. const char *prop = m_Makefile->GetProperty(args[1].c_str());
  91. if (prop)
  92. {
  93. m_Makefile->AddDefinition(variable.c_str(), prop);
  94. return true;
  95. }
  96. std::string emsg = "Unknown directory property: " + args[1];
  97. this->SetError(emsg.c_str());
  98. return false;
  99. }
  100. m_Makefile->AddDefinition(variable.c_str(), output.c_str());
  101. return true;
  102. }