cmLoadCacheCommand.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. #ifndef cmLoadCacheCommand_h
  14. #define cmLoadCacheCommand_h
  15. #include "cmCommand.h"
  16. /** \class cmLoadCacheCommand
  17. * \brief load a cache file
  18. *
  19. * cmLoadCacheCommand loads the non internal values of a cache file
  20. */
  21. class cmLoadCacheCommand : public cmCommand
  22. {
  23. public:
  24. /**
  25. * This is a virtual constructor for the command.
  26. */
  27. virtual cmCommand* Clone()
  28. {
  29. return new cmLoadCacheCommand;
  30. }
  31. /**
  32. * This is called when the command is first encountered in
  33. * the CMakeLists.txt file.
  34. */
  35. virtual bool InitialPass(std::vector<std::string> const& args);
  36. /**
  37. * This determines if the command gets propagated down
  38. * to makefiles located in subdirectories.
  39. */
  40. virtual bool IsInherited() {return true;}
  41. /**
  42. * The name of the command as specified in CMakeList.txt.
  43. */
  44. virtual const char* GetName() { return "LOAD_CACHE";}
  45. /**
  46. * Succinct documentation.
  47. */
  48. virtual const char* GetTerseDocumentation()
  49. {
  50. return "Load in the values from another project's CMake cache.";
  51. }
  52. /**
  53. * More documentation.
  54. */
  55. virtual const char* GetFullDocumentation()
  56. {
  57. return
  58. " LOAD_CACHE(pathToCacheFile READ_WITH_PREFIX\n"
  59. " prefix entry1...)\n"
  60. "Read the cache and store the requested entries in variables with "
  61. "their name prefixed with the given prefix. "
  62. "This only reads the values, and does not create entries in the local "
  63. "project's cache.\n"
  64. " LOAD_CACHE(pathToCacheFile [EXCLUDE entry1...]\n"
  65. " [INCLUDE_INTERNALS entry1...])\n"
  66. "Load in the values from another cache and store them in the local "
  67. "project's cache as internal entries. This is useful for a project "
  68. "that depends on another project built in a different tree. "
  69. "EXCLUDE option can be used to provide a list of entries to be "
  70. "excluded. "
  71. "INCLUDE_INTERNALS can be used to provide a list of internal entries"
  72. "to be included. Normally, no internal entries are brougt in. Use "
  73. "of this form of the command is strongly discouraged, but it is "
  74. "provided for backward compatability.";
  75. }
  76. cmTypeMacro(cmLoadCacheCommand, cmCommand);
  77. protected:
  78. std::set<cmStdString> VariablesToRead;
  79. std::string Prefix;
  80. bool ReadWithPrefix(std::vector<std::string> const& args);
  81. void CheckLine(const char* line);
  82. bool ParseEntry(const char* entry, std::string& var, std::string& value);
  83. };
  84. #endif