1export 2------ 3 4Export targets from the build tree for use by outside projects. 5 6.. code-block:: cmake 7 8 export(EXPORT <export-name> [NAMESPACE <namespace>] [FILE <filename>]) 9 10Creates a file ``<filename>`` that may be included by outside projects to 11import targets from the current project's build tree. This is useful 12during cross-compiling to build utility executables that can run on 13the host platform in one project and then import them into another 14project being compiled for the target platform. If the ``NAMESPACE`` 15option is given the ``<namespace>`` string will be prepended to all target 16names written to the file. 17 18Target installations are associated with the export ``<export-name>`` 19using the ``EXPORT`` option of the :command:`install(TARGETS)` command. 20 21The file created by this command is specific to the build tree and 22should never be installed. See the :command:`install(EXPORT)` command to 23export targets from an installation tree. 24 25The properties set on the generated IMPORTED targets will have the 26same values as the final values of the input TARGETS. 27 28.. code-block:: cmake 29 30 export(TARGETS [target1 [target2 [...]]] [NAMESPACE <namespace>] 31 [APPEND] FILE <filename> [EXPORT_LINK_INTERFACE_LIBRARIES]) 32 33This signature is similar to the ``EXPORT`` signature, but targets are listed 34explicitly rather than specified as an export-name. If the APPEND option is 35given the generated code will be appended to the file instead of overwriting it. 36The EXPORT_LINK_INTERFACE_LIBRARIES keyword, if present, causes the 37contents of the properties matching 38``(IMPORTED_)?LINK_INTERFACE_LIBRARIES(_<CONFIG>)?`` to be exported, when 39policy CMP0022 is NEW. If a library target is included in the export 40but a target to which it links is not included the behavior is 41unspecified. 42 43.. note:: 44 45 :ref:`Object Libraries` under :generator:`Xcode` have special handling if 46 multiple architectures are listed in :variable:`CMAKE_OSX_ARCHITECTURES`. 47 In this case they will be exported as :ref:`Interface Libraries` with 48 no object files available to clients. This is sufficient to satisfy 49 transitive usage requirements of other targets that link to the 50 object libraries in their implementation. 51 52.. code-block:: cmake 53 54 export(PACKAGE <PackageName>) 55 56Store the current build directory in the CMake user package registry 57for package ``<PackageName>``. The :command:`find_package` command may consider the 58directory while searching for package ``<PackageName>``. This helps dependent 59projects find and use a package from the current project's build tree 60without help from the user. Note that the entry in the package 61registry that this command creates works only in conjunction with a 62package configuration file (``<PackageName>Config.cmake``) that works with the 63build tree. In some cases, for example for packaging and for system 64wide installations, it is not desirable to write the user package 65registry. 66 67.. versionchanged:: 3.1 68 If the :variable:`CMAKE_EXPORT_NO_PACKAGE_REGISTRY` variable 69 is enabled, the ``export(PACKAGE)`` command will do nothing. 70 71.. versionchanged:: 3.15 72 By default the ``export(PACKAGE)`` command does nothing (see policy 73 :policy:`CMP0090`) because populating the user package registry has effects 74 outside the source and build trees. Set the 75 :variable:`CMAKE_EXPORT_PACKAGE_REGISTRY` variable to add build directories 76 to the CMake user package registry. 77 78.. code-block:: cmake 79 80 export(TARGETS [target1 [target2 [...]]] [ANDROID_MK <filename>]) 81 82.. versionadded:: 3.7 83 84This signature exports cmake built targets to the android ndk build system 85by creating an Android.mk file that references the prebuilt targets. The 86Android NDK supports the use of prebuilt libraries, both static and shared. 87This allows cmake to build the libraries of a project and make them available 88to an ndk build system complete with transitive dependencies, include flags 89and defines required to use the libraries. The signature takes a list of 90targets and puts them in the Android.mk file specified by the ``<filename>`` 91given. This signature can only be used if policy CMP0022 is NEW for all 92targets given. A error will be issued if that policy is set to OLD for one 93of the targets. 94