cmExportCommand.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. #include "cmDocumentLocationUndefined.h"
  14. class cmExportBuildFileGenerator;
  15. /** \class cmExportLibraryDependenciesCommand
  16. * \brief Add a test to the lists of tests to run.
  17. *
  18. * cmExportLibraryDependenciesCommand adds a test to the list of tests to run
  19. *
  20. */
  21. class cmExportCommand : public cmCommand
  22. {
  23. public:
  24. cmExportCommand();
  25. /**
  26. * This is a virtual constructor for the command.
  27. */
  28. virtual cmCommand* Clone()
  29. {
  30. return new cmExportCommand;
  31. }
  32. /**
  33. * This is called when the command is first encountered in
  34. * the CMakeLists.txt file.
  35. */
  36. virtual bool InitialPass(std::vector<std::string> const& args,
  37. cmExecutionStatus &status);
  38. /**
  39. * The name of the command as specified in CMakeList.txt.
  40. */
  41. virtual const char* GetName() const { return "export";}
  42. /**
  43. * Succinct documentation.
  44. */
  45. virtual const char* GetTerseDocumentation() const
  46. {
  47. return
  48. "Export targets from the build tree for use by outside projects.";
  49. }
  50. /**
  51. * More documentation.
  52. */
  53. virtual const char* GetFullDocumentation() const
  54. {
  55. return
  56. " export(TARGETS [target1 [target2 [...]]] [NAMESPACE <namespace>]\n"
  57. " [APPEND] FILE <filename> [EXPORT_LINK_INTERFACE_LIBRARIES])\n"
  58. "Create a file <filename> that may be included by outside projects to "
  59. "import targets from the current project's build tree. "
  60. "This is useful during cross-compiling to build utility executables "
  61. "that can run on the host platform in one project and then import "
  62. "them into another project being compiled for the target platform. "
  63. "If the NAMESPACE option is given the <namespace> string will be "
  64. "prepended to all target names written to the file. "
  65. "If the APPEND option is given the generated code will be appended "
  66. "to the file instead of overwriting it. "
  67. "The EXPORT_LINK_INTERFACE_LIBRARIES keyword, if present, causes the "
  68. "contents of the properties matching "
  69. "(IMPORTED_)?LINK_INTERFACE_LIBRARIES(_<CONFIG>)? to be exported, when "
  70. "policy CMP0022 is NEW. "
  71. "If a library target is included in the export but "
  72. "a target to which it links is not included the behavior is "
  73. "unspecified."
  74. "\n"
  75. "The file created by this command is specific to the build tree and "
  76. "should never be installed. "
  77. "See the install(EXPORT) command to export targets from an "
  78. "installation tree."
  79. "\n"
  80. "The properties set on the generated IMPORTED targets will have the "
  81. "same values as the final values of the input TARGETS."
  82. "\n"
  83. " export(PACKAGE <name>)\n"
  84. "Store the current build directory in the CMake user package registry "
  85. "for package <name>. "
  86. "The find_package command may consider the directory while searching "
  87. "for package <name>. "
  88. "This helps dependent projects find and use a package from the "
  89. "current project's build tree without help from the user. "
  90. "Note that the entry in the package registry that this command "
  91. "creates works only in conjunction with a package configuration "
  92. "file (<name>Config.cmake) that works with the build tree."
  93. ;
  94. }
  95. cmTypeMacro(cmExportCommand, cmCommand);
  96. private:
  97. cmCommandArgumentGroup ArgumentGroup;
  98. cmCAStringVector Targets;
  99. cmCAEnabler Append;
  100. cmCAString Namespace;
  101. cmCAString Filename;
  102. cmCAEnabler ExportOld;
  103. friend class cmExportBuildFileGenerator;
  104. std::string ErrorMessage;
  105. bool HandlePackage(std::vector<std::string> const& args);
  106. void StorePackageRegistryWin(std::string const& package,
  107. const char* content, const char* hash);
  108. void StorePackageRegistryDir(std::string const& package,
  109. const char* content, const char* hash);
  110. void ReportRegistryError(std::string const& msg, std::string const& key,
  111. long err);
  112. };
  113. #endif