summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-07-14 13:37:51 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2014-07-14 13:37:51 (GMT)
commitcb867dc4f4bb17d3fd9a5182ac8b789a9dc01818 (patch)
tree91393863b23204c52c3ec6668b83105963686f41
parent27fb86d72e254802e595f9e9fb1df10cf15fcf03 (diff)
parentcfab942e5ff8463f8053564e68179da110280b43 (diff)
downloadCMake-cb867dc4f4bb17d3fd9a5182ac8b789a9dc01818.zip
CMake-cb867dc4f4bb17d3fd9a5182ac8b789a9dc01818.tar.gz
CMake-cb867dc4f4bb17d3fd9a5182ac8b789a9dc01818.tar.bz2
Merge topic 'doc-package-target-import-once'
cfab942e Help: Update cmake-packages.7 examples to import targets only once
-rw-r--r--Help/manual/cmake-packages.7.rst15
1 files changed, 11 insertions, 4 deletions
diff --git a/Help/manual/cmake-packages.7.rst b/Help/manual/cmake-packages.7.rst
index c4cca6d..5badd48 100644
--- a/Help/manual/cmake-packages.7.rst
+++ b/Help/manual/cmake-packages.7.rst
@@ -385,9 +385,12 @@ In this case, the ``ClimbingStatsConfig.cmake`` file could be as simple as:
.. code-block:: cmake
- include("${CMAKE_CURRENT_LIST_DIR}/ClimbingStatsTargets.cmake")
+ if(NOT TARGET Upstream::ClimbingStats)
+ include("${CMAKE_CURRENT_LIST_DIR}/ClimbingStatsTargets.cmake")
+ endif()
-As this allows downstreams to use the ``IMPORTED`` targets. If any macros
+This allows downstreams to use the ``IMPORTED`` targets, and guards
+against importing the targets more than once. If any macros
should be provided by the ``ClimbingStats`` package, they should
be in a separate file which is installed to the same location as the
``ClimbingStatsConfig.cmake`` file, and included from there.
@@ -454,7 +457,9 @@ dependencies of a package should be found in the ``Config.cmake`` file:
include(CMakeFindDependencyMacro)
find_dependency(Stats 2.6.4)
- include("${CMAKE_CURRENT_LIST_DIR}/ClimbingStatsTargets.cmake")
+ if(NOT TARGET Upstream::ClimbingStats)
+ include("${CMAKE_CURRENT_LIST_DIR}/ClimbingStatsTargets.cmake")
+ endif()
include("${CMAKE_CURRENT_LIST_DIR}/ClimbingStatsMacros.cmake")
The ``find_dependency`` macro also sets ``ClimbingStats_FOUND`` to ``False`` if
@@ -471,7 +476,9 @@ be true. This can be tested with logic in the package configuration file:
include(CMakeFindDependencyMacro)
find_dependency(Stats 2.6.4)
- include("${CMAKE_CURRENT_LIST_DIR}/ClimbingStatsTargets.cmake")
+ if(NOT TARGET Upstream::ClimbingStats)
+ include("${CMAKE_CURRENT_LIST_DIR}/ClimbingStatsTargets.cmake")
+ endif()
include("${CMAKE_CURRENT_LIST_DIR}/ClimbingStatsMacros.cmake")
set(_supported_components Plot Table)