cmGetCMakePropertyCommand.cxx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. std::vector<std::string> vars = this->Makefile->GetDefinitions();
  30. if (!vars.empty())
  31. {
  32. output = cmJoin(vars, ";");
  33. }
  34. }
  35. else if ( args[1] == "MACROS" )
  36. {
  37. output.clear();
  38. if (const char* macrosProp = this->Makefile->GetProperty("MACROS"))
  39. {
  40. output = macrosProp;
  41. }
  42. }
  43. else if ( args[1] == "COMPONENTS" )
  44. {
  45. const std::set<std::string>* components
  46. = this->Makefile->GetGlobalGenerator()->GetInstallComponents();
  47. output = cmJoin(*components, ";");
  48. }
  49. else
  50. {
  51. const char *prop = 0;
  52. if (!args[1].empty())
  53. {
  54. prop = this->Makefile->GetState()->GetGlobalProperty(args[1]);
  55. }
  56. if (prop)
  57. {
  58. output = prop;
  59. }
  60. }
  61. this->Makefile->AddDefinition(variable, output.c_str());
  62. return true;
  63. }