cmExportCommand.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef cmExportCommand_h
  11. #define cmExportCommand_h
  12. #include "cmCommand.h"
  13. class cmExportBuildFileGenerator;
  14. /** \class cmExportLibraryDependenciesCommand
  15. * \brief Add a test to the lists of tests to run.
  16. *
  17. * cmExportLibraryDependenciesCommand adds a test to the list of tests to run
  18. *
  19. */
  20. class cmExportCommand : public cmCommand
  21. {
  22. public:
  23. cmExportCommand();
  24. /**
  25. * This is a virtual constructor for the command.
  26. */
  27. virtual cmCommand* Clone()
  28. {
  29. return new cmExportCommand;
  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. cmExecutionStatus &status);
  37. /**
  38. * The name of the command as specified in CMakeList.txt.
  39. */
  40. virtual const char* GetName() { return "export";}
  41. /**
  42. * Succinct documentation.
  43. */
  44. virtual const char* GetTerseDocumentation()
  45. {
  46. return
  47. "Export targets from the build tree for use by outside projects.";
  48. }
  49. /**
  50. * More documentation.
  51. */
  52. virtual const char* GetFullDocumentation()
  53. {
  54. return
  55. " export(TARGETS [target1 [target2 [...]]] [NAMESPACE <namespace>]\n"
  56. " [APPEND] FILE <filename>)\n"
  57. "Create a file <filename> that may be included by outside projects to "
  58. "import targets from the current project's build tree. "
  59. "This is useful during cross-compiling to build utility executables "
  60. "that can run on the host platform in one project and then import "
  61. "them into another project being compiled for the target platform. "
  62. "If the NAMESPACE option is given the <namespace> string will be "
  63. "prepended to all target names written to the file. "
  64. "If the APPEND option is given the generated code will be appended "
  65. "to the file instead of overwriting it. "
  66. "If a library target is included in the export but "
  67. "a target to which it links is not included the behavior is "
  68. "unspecified."
  69. "\n"
  70. "The file created by this command is specific to the build tree and "
  71. "should never be installed. "
  72. "See the install(EXPORT) command to export targets from an "
  73. "installation tree."
  74. "\n"
  75. " export(PACKAGE <name>)\n"
  76. "Store the current build directory in the CMake user package registry "
  77. "for package <name>. "
  78. "The find_package command may consider the directory while searching "
  79. "for package <name>. "
  80. "This helps dependent projects find and use a package from the "
  81. "current project's build tree without help from the user. "
  82. "Note that the entry in the package registry that this command "
  83. "creates works only in conjunction with a package configuration "
  84. "file (<name>Config.cmake) that works with the build tree."
  85. ;
  86. }
  87. cmTypeMacro(cmExportCommand, cmCommand);
  88. private:
  89. cmCommandArgumentGroup ArgumentGroup;
  90. cmCAStringVector Targets;
  91. cmCAEnabler Append;
  92. cmCAString Namespace;
  93. cmCAString Filename;
  94. friend class cmExportBuildFileGenerator;
  95. std::string ErrorMessage;
  96. bool HandlePackage(std::vector<std::string> const& args);
  97. void StorePackageRegistryWin(std::string const& package,
  98. const char* content, const char* hash);
  99. void StorePackageRegistryDir(std::string const& package,
  100. const char* content, const char* hash);
  101. void ReportRegistryError(std::string const& msg, std::string const& key,
  102. long err);
  103. };
  104. #endif