export.rst 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. export
  2. ------
  3. Export targets from the build tree for use by outside projects.
  4. ::
  5. export(EXPORT <export-name> [NAMESPACE <namespace>] [FILE <filename>])
  6. Create a file <filename> that may be included by outside projects to
  7. import targets from the current project's build tree. This is useful
  8. during cross-compiling to build utility executables that can run on
  9. the host platform in one project and then import them into another
  10. project being compiled for the target platform. If the NAMESPACE
  11. option is given the <namespace> string will be prepended to all target
  12. names written to the file.
  13. Target installations are associated with the export <export-name>
  14. using the ``EXPORT`` option of the :command:`install(TARGETS)` command.
  15. The file created by this command is specific to the build tree and
  16. should never be installed. See the install(EXPORT) command to export
  17. targets from an installation tree.
  18. The properties set on the generated IMPORTED targets will have the
  19. same values as the final values of the input TARGETS.
  20. ::
  21. export(TARGETS [target1 [target2 [...]]] [NAMESPACE <namespace>]
  22. [APPEND] FILE <filename> [EXPORT_LINK_INTERFACE_LIBRARIES])
  23. This signature is similar to the ``EXPORT`` signature, but targets are listed
  24. explicitly rather than specified as an export-name. If the APPEND option is
  25. given the generated code will be appended to the file instead of overwriting it.
  26. The EXPORT_LINK_INTERFACE_LIBRARIES keyword, if present, causes the
  27. contents of the properties matching
  28. ``(IMPORTED_)?LINK_INTERFACE_LIBRARIES(_<CONFIG>)?`` to be exported, when
  29. policy CMP0022 is NEW. If a library target is included in the export
  30. but a target to which it links is not included the behavior is
  31. unspecified.
  32. ::
  33. export(PACKAGE <name>)
  34. Store the current build directory in the CMake user package registry
  35. for package <name>. The find_package command may consider the
  36. directory while searching for package <name>. This helps dependent
  37. projects find and use a package from the current project's build tree
  38. without help from the user. Note that the entry in the package
  39. registry that this command creates works only in conjunction with a
  40. package configuration file (<name>Config.cmake) that works with the
  41. build tree. In some cases, for example for packaging and for system
  42. wide installations, it is not desirable to write the user package
  43. registry. If the :variable:`CMAKE_EXPORT_NO_PACKAGE_REGISTRY` variable
  44. is enabled, the ``export(PACKAGE)`` command will do nothing.