export.rst 1.9 KB

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