cmGetCMakePropertyCommand.cxx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmGetCMakePropertyCommand.h"
  11. #include "cmake.h"
  12. // cmGetCMakePropertyCommand
  13. bool cmGetCMakePropertyCommand
  14. ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
  15. {
  16. if(args.size() < 2 )
  17. {
  18. this->SetError("called with incorrect number of arguments");
  19. return false;
  20. }
  21. std::vector<std::string>::size_type cc;
  22. std::string variable = args[0];
  23. std::string output = "NOTFOUND";
  24. if ( args[1] == "VARIABLES")
  25. {
  26. int cacheonly = 0;
  27. std::vector<std::string> vars = this->Makefile->GetDefinitions(cacheonly);
  28. for ( cc = 0; cc < vars.size(); cc ++ )
  29. {
  30. if ( cc > 0 )
  31. {
  32. output += ";";
  33. }
  34. output += vars[cc];
  35. }
  36. }
  37. else if ( args[1] == "MACROS" )
  38. {
  39. this->Makefile->GetListOfMacros(output);
  40. }
  41. else if ( args[1] == "COMPONENTS" )
  42. {
  43. const std::set<cmStdString>* components
  44. = this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
  45. ->GetInstallComponents();
  46. std::set<cmStdString>::const_iterator compIt;
  47. output = "";
  48. for (compIt = components->begin(); compIt != components->end(); ++compIt)
  49. {
  50. if (compIt != components->begin())
  51. {
  52. output += ";";
  53. }
  54. output += *compIt;
  55. }
  56. }
  57. else
  58. {
  59. const char *prop =
  60. this->Makefile->GetCMakeInstance()->GetProperty(args[1].c_str());
  61. if (prop)
  62. {
  63. output = prop;
  64. }
  65. }
  66. this->Makefile->AddDefinition(variable.c_str(), output.c_str());
  67. return true;
  68. }