cmGetCMakePropertyCommand.cxx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 "cmGlobalGenerator.h"
  12. #include "cmLocalGenerator.h"
  13. #include "cmake.h"
  14. // cmGetCMakePropertyCommand
  15. bool cmGetCMakePropertyCommand
  16. ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
  17. {
  18. if(args.size() < 2 )
  19. {
  20. this->SetError("called with incorrect number of arguments");
  21. return false;
  22. }
  23. std::vector<std::string>::size_type cc;
  24. std::string variable = args[0];
  25. std::string output = "NOTFOUND";
  26. if ( args[1] == "VARIABLES" )
  27. {
  28. int cacheonly = 0;
  29. std::vector<std::string> vars = this->Makefile->GetDefinitions(cacheonly);
  30. if (!vars.empty())
  31. {
  32. output = vars[0];
  33. }
  34. for ( cc = 1; cc < vars.size(); ++cc )
  35. {
  36. output += ";";
  37. output += vars[cc];
  38. }
  39. }
  40. else if ( args[1] == "MACROS" )
  41. {
  42. this->Makefile->GetListOfMacros(output);
  43. }
  44. else if ( args[1] == "COMPONENTS" )
  45. {
  46. const std::set<std::string>* components
  47. = this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
  48. ->GetInstallComponents();
  49. std::set<std::string>::const_iterator compIt;
  50. output = "";
  51. for (compIt = components->begin(); compIt != components->end(); ++compIt)
  52. {
  53. if (compIt != components->begin())
  54. {
  55. output += ";";
  56. }
  57. output += *compIt;
  58. }
  59. }
  60. else
  61. {
  62. const char *prop =
  63. this->Makefile->GetCMakeInstance()->GetProperty(args[1]);
  64. if (prop)
  65. {
  66. output = prop;
  67. }
  68. }
  69. this->Makefile->AddDefinition(variable, output.c_str());
  70. return true;
  71. }