1
0

cmGetCMakePropertyCommand.cxx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. if (vars.size()>0)
  29. {
  30. output = vars[0];
  31. }
  32. for ( cc = 1; cc < vars.size(); ++cc )
  33. {
  34. output += ";";
  35. output += vars[cc];
  36. }
  37. }
  38. else if ( args[1] == "MACROS" )
  39. {
  40. this->Makefile->GetListOfMacros(output);
  41. }
  42. else if ( args[1] == "COMPONENTS" )
  43. {
  44. const std::set<cmStdString>* components
  45. = this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
  46. ->GetInstallComponents();
  47. std::set<cmStdString>::const_iterator compIt;
  48. output = "";
  49. for (compIt = components->begin(); compIt != components->end(); ++compIt)
  50. {
  51. if (compIt != components->begin())
  52. {
  53. output += ";";
  54. }
  55. output += *compIt;
  56. }
  57. }
  58. else
  59. {
  60. const char *prop =
  61. this->Makefile->GetCMakeInstance()->GetProperty(args[1].c_str());
  62. if (prop)
  63. {
  64. output = prop;
  65. }
  66. }
  67. this->Makefile->AddDefinition(variable.c_str(), output.c_str());
  68. return true;
  69. }