cmGetCMakePropertyCommand.cxx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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
  44. {
  45. std::string emsg = "Unknown CMake property: " + args[1];
  46. this->SetError(emsg.c_str());
  47. return false;
  48. }
  49. m_Makefile->AddDefinition(variable.c_str(), output.c_str());
  50. return true;
  51. }