cmLoadCacheCommand.h 3.0 KB

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