cmGetCMakePropertyCommand.cxx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #include "cmState.h"
  15. #include "cmAlgorithms.h"
  16. // cmGetCMakePropertyCommand
  17. bool cmGetCMakePropertyCommand
  18. ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
  19. {
  20. if(args.size() < 2 )
  21. {
  22. this->SetError("called with incorrect number of arguments");
  23. return false;
  24. }
  25. std::string variable = args[0];
  26. std::string output = "NOTFOUND";
  27. if ( args[1] == "VARIABLES" )
  28. {
  29. int cacheonly = 0;
  30. std::vector<std::string> vars = this->Makefile->GetDefinitions(cacheonly);
  31. if (!vars.empty())
  32. {
  33. output = cmJoin(vars, ";");
  34. }
  35. }
  36. else if ( args[1] == "MACROS" )
  37. {
  38. output.clear();
  39. this->Makefile->GetListOfMacros(output);
  40. }
  41. else if ( args[1] == "COMPONENTS" )
  42. {
  43. const std::set<std::string>* components
  44. = this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
  45. ->GetInstallComponents();
  46. output = cmJoin(*components, ";");
  47. }
  48. else
  49. {
  50. const char *prop =
  51. this->Makefile->GetState()
  52. ->GetGlobalProperty(args[1]);
  53. if (prop)
  54. {
  55. output = prop;
  56. }
  57. }
  58. this->Makefile->AddDefinition(variable, output.c_str());
  59. return true;
  60. }