cmGetCMakePropertyCommand.cxx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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::string variable = args[0];
  24. std::string output = "NOTFOUND";
  25. if ( args[1] == "VARIABLES" )
  26. {
  27. int cacheonly = 0;
  28. std::vector<std::string> vars = this->Makefile->GetDefinitions(cacheonly);
  29. if (!vars.empty())
  30. {
  31. output = cmJoin(vars, ";");
  32. }
  33. }
  34. else if ( args[1] == "MACROS" )
  35. {
  36. output.clear();
  37. this->Makefile->GetListOfMacros(output);
  38. }
  39. else if ( args[1] == "COMPONENTS" )
  40. {
  41. const std::set<std::string>* components
  42. = this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
  43. ->GetInstallComponents();
  44. output = cmJoin(*components, ";");
  45. }
  46. else
  47. {
  48. const char *prop =
  49. this->Makefile->GetCMakeInstance()->GetProperty(args[1]);
  50. if (prop)
  51. {
  52. output = prop;
  53. }
  54. }
  55. this->Makefile->AddDefinition(variable, output.c_str());
  56. return true;
  57. }