Help: Document export(EXPORT) in the cmake-packages manual.
This commit is contained in:
parent
a1d2bda23e
commit
98b9f52bc9
@ -266,6 +266,7 @@ shared library:
|
|||||||
project(UpstreamLib)
|
project(UpstreamLib)
|
||||||
|
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON)
|
||||||
|
|
||||||
set(Upstream_VERSION 3.4.1)
|
set(Upstream_VERSION 3.4.1)
|
||||||
|
|
||||||
@ -292,11 +293,20 @@ shared library:
|
|||||||
|
|
||||||
include(CMakePackageConfigHelpers)
|
include(CMakePackageConfigHelpers)
|
||||||
write_basic_package_version_file(
|
write_basic_package_version_file(
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/ClimbingStatsConfigVersion.cmake"
|
"${CMAKE_CURRENT_BINARY_DIR}/ClimbingStats/ClimbingStatsConfigVersion.cmake"
|
||||||
VERSION ${Upstream_VERSION}
|
VERSION ${Upstream_VERSION}
|
||||||
COMPATIBILITY AnyNewerVersion
|
COMPATIBILITY AnyNewerVersion
|
||||||
)
|
)
|
||||||
|
|
||||||
|
export(EXPORT ClimbingStatsTargets
|
||||||
|
FILE "${CMAKE_CURRENT_BINARY_DIR}/ClimbingStats/ClimbingStatsTargets.cmake"
|
||||||
|
NAMESPACE Upstream::
|
||||||
|
)
|
||||||
|
configure_file(cmake/ClimbingStatsConfig.cmake
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/ClimbingStats/ClimbingStatsConfig.cmake"
|
||||||
|
COPY_ONLY
|
||||||
|
)
|
||||||
|
|
||||||
set(ConfigPackageLocation lib/cmake/ClimbingStats)
|
set(ConfigPackageLocation lib/cmake/ClimbingStats)
|
||||||
install(EXPORT ClimbingStatsTargets
|
install(EXPORT ClimbingStatsTargets
|
||||||
FILE
|
FILE
|
||||||
@ -309,7 +319,7 @@ shared library:
|
|||||||
install(
|
install(
|
||||||
FILES
|
FILES
|
||||||
cmake/ClimbingStatsConfig.cmake
|
cmake/ClimbingStatsConfig.cmake
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/ClimbingStatsConfigVersion.cmake"
|
"${CMAKE_CURRENT_BINARY_DIR}/ClimbingStats/ClimbingStatsConfigVersion.cmake"
|
||||||
DESTINATION
|
DESTINATION
|
||||||
${ConfigPackageLocation}
|
${ConfigPackageLocation}
|
||||||
COMPONENT
|
COMPONENT
|
||||||
@ -354,6 +364,14 @@ should be provided by the ``ClimbingStats`` package, they should
|
|||||||
be in a separate file which is installed to the same location as the
|
be in a separate file which is installed to the same location as the
|
||||||
``ClimbingStatsConfig.cmake`` file, and included from there.
|
``ClimbingStatsConfig.cmake`` file, and included from there.
|
||||||
|
|
||||||
|
The :command:`export(EXPORT)` command creates an :prop_tgt:`IMPORTED` targets
|
||||||
|
definition file which is specific to the build-tree. This can similiarly be
|
||||||
|
used with a suitable package configuration file and package version file to
|
||||||
|
define a package for the build tree which may be used without installation.
|
||||||
|
Consumers of the build tree can simply ensure that the
|
||||||
|
:variable:`CMAKE_PREFIX_PATH` contains the build directory, or set the
|
||||||
|
``ClimbingStats_DIR`` to ``<build_dir>/ClimbingStats`` in the cache.
|
||||||
|
|
||||||
This can also be extended to cover dependencies:
|
This can also be extended to cover dependencies:
|
||||||
|
|
||||||
.. code-block:: cmake
|
.. code-block:: cmake
|
||||||
|
Loading…
x
Reference in New Issue
Block a user