cmGetCMakePropertyCommand.cxx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. // cmGetCMakePropertyCommand
  15. bool cmGetCMakePropertyCommand::InitialPass(
  16. std::vector<std::string> const& args)
  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 = "";
  26. if ( args[1] == "VARIABLES" || args[1] == "CACHE_VARIABLES" )
  27. {
  28. int cacheonly = 0;
  29. if ( args[1] == "CACHE_VARIABLES" )
  30. {
  31. cacheonly = 1;
  32. }
  33. std::vector<std::string> vars = m_Makefile->GetDefinitions(cacheonly);
  34. for ( cc = 0; cc < vars.size(); cc ++ )
  35. {
  36. if ( cc > 0 )
  37. {
  38. output += ";";
  39. }
  40. output += vars[cc];
  41. }
  42. }
  43. else if ( args[1] == "COMMANDS" )
  44. {
  45. cmake::RegisteredCommandsMap::iterator cmds
  46. = m_Makefile->GetCMakeInstance()->GetCommands()->begin();
  47. for (cc=0 ;
  48. cmds != m_Makefile->GetCMakeInstance()->GetCommands()->end();
  49. ++ cmds )
  50. {
  51. if ( cc > 0 )
  52. {
  53. output += ";";
  54. }
  55. output += cmds->first.c_str();
  56. cc++;
  57. }
  58. }
  59. else
  60. {
  61. std::string emsg = "Unknown CMake property: " + args[1];
  62. this->SetError(emsg.c_str());
  63. return false;
  64. }
  65. m_Makefile->AddDefinition(variable.c_str(), output.c_str());
  66. return true;
  67. }