cmGetCMakePropertyCommand.cxx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 if ( args[1] == "MACROS" )
  60. {
  61. m_Makefile->GetListOfMacros(output);
  62. }
  63. else
  64. {
  65. std::string emsg = "Unknown CMake property: " + args[1];
  66. this->SetError(emsg.c_str());
  67. return false;
  68. }
  69. m_Makefile->AddDefinition(variable.c_str(), output.c_str());
  70. return true;
  71. }