cmLoadCacheCommand.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. * The name of the command as specified in CMakeList.txt.
  38. */
  39. virtual const char* GetName() { return "LOAD_CACHE";}
  40. /**
  41. * Succinct documentation.
  42. */
  43. virtual const char* GetTerseDocumentation()
  44. {
  45. return "Load in the values from another project's CMake cache.";
  46. }
  47. /**
  48. * More documentation.
  49. */
  50. virtual const char* GetFullDocumentation()
  51. {
  52. return
  53. " LOAD_CACHE(pathToCacheFile READ_WITH_PREFIX\n"
  54. " prefix entry1...)\n"
  55. "Read the cache and store the requested entries in variables with "
  56. "their name prefixed with the given prefix. "
  57. "This only reads the values, and does not create entries in the local "
  58. "project's cache.\n"
  59. " LOAD_CACHE(pathToCacheFile [EXCLUDE entry1...]\n"
  60. " [INCLUDE_INTERNALS entry1...])\n"
  61. "Load in the values from another cache and store them in the local "
  62. "project's cache as internal entries. This is useful for a project "
  63. "that depends on another project built in a different tree. "
  64. "EXCLUDE option can be used to provide a list of entries to be "
  65. "excluded. "
  66. "INCLUDE_INTERNALS can be used to provide a list of internal entries "
  67. "to be included. Normally, no internal entries are brought in. Use "
  68. "of this form of the command is strongly discouraged, but it is "
  69. "provided for backward compatibility.";
  70. }
  71. cmTypeMacro(cmLoadCacheCommand, cmCommand);
  72. protected:
  73. std::set<cmStdString> VariablesToRead;
  74. std::string Prefix;
  75. bool ReadWithPrefix(std::vector<std::string> const& args);
  76. void CheckLine(const char* line);
  77. bool ParseEntry(const char* entry, std::string& var, std::string& value);
  78. };
  79. #endif