cmGetCMakePropertyCommand.cxx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #include "cmGetCMakePropertyCommand.h"
  14. #include "cmake.h"
  15. // cmGetCMakePropertyCommand
  16. bool cmGetCMakePropertyCommand::InitialPass(
  17. std::vector<std::string> const& args)
  18. {
  19. if(args.size() < 2 )
  20. {
  21. this->SetError("called with incorrect number of arguments");
  22. return false;
  23. }
  24. std::vector<std::string>::size_type cc;
  25. std::string variable = args[0];
  26. std::string output = "";
  27. if ( args[1] == "VARIABLES" || args[1] == "CACHE_VARIABLES" )
  28. {
  29. int cacheonly = 0;
  30. if ( args[1] == "CACHE_VARIABLES" )
  31. {
  32. cacheonly = 1;
  33. }
  34. std::vector<std::string> vars = this->Makefile->GetDefinitions(cacheonly);
  35. for ( cc = 0; cc < vars.size(); cc ++ )
  36. {
  37. if ( cc > 0 )
  38. {
  39. output += ";";
  40. }
  41. output += vars[cc];
  42. }
  43. }
  44. else if ( args[1] == "COMMANDS" )
  45. {
  46. cmake::RegisteredCommandsMap::iterator cmds
  47. = this->Makefile->GetCMakeInstance()->GetCommands()->begin();
  48. for (cc=0 ;
  49. cmds != this->Makefile->GetCMakeInstance()->GetCommands()->end();
  50. ++ cmds )
  51. {
  52. if ( cc > 0 )
  53. {
  54. output += ";";
  55. }
  56. output += cmds->first.c_str();
  57. cc++;
  58. }
  59. }
  60. else if ( args[1] == "MACROS" )
  61. {
  62. this->Makefile->GetListOfMacros(output);
  63. }
  64. else
  65. {
  66. std::string emsg = "Unknown CMake property: " + args[1];
  67. this->SetError(emsg.c_str());
  68. return false;
  69. }
  70. this->Makefile->AddDefinition(variable.c_str(), output.c_str());
  71. return true;
  72. }