summaryrefslogtreecommitdiffstats
path: root/Help
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2014-12-04 22:56:21 (GMT)
committerStephen Kelly <steveire@gmail.com>2014-12-04 23:12:14 (GMT)
commite18e21aeb52923d470680aa171f722b4d3b5d01d (patch)
tree024762299c1efe85c2ecc519a9e78e7dacb583d0 /Help
parentf0d0d761b2150e41397af8cfce2b846107cf8921 (diff)
downloadCMake-e18e21aeb52923d470680aa171f722b4d3b5d01d.zip
CMake-e18e21aeb52923d470680aa171f722b4d3b5d01d.tar.gz
CMake-e18e21aeb52923d470680aa171f722b4d3b5d01d.tar.bz2
Help: Document IMPORTED_CONFIGURATIONS target property for Find modules.
Diffstat (limited to 'Help')
-rw-r--r--Help/manual/cmake-developer.7.rst41
1 files changed, 40 insertions, 1 deletions
diff --git a/Help/manual/cmake-developer.7.rst b/Help/manual/cmake-developer.7.rst
index 94fc019..6f7bbdc 100644
--- a/Help/manual/cmake-developer.7.rst
+++ b/Help/manual/cmake-developer.7.rst
@@ -876,7 +876,10 @@ To prevent users being overwhelmed with settings to configure, try to
keep as many options as possible out of the cache, leaving at least one
option which can be used to disable use of the module, or locate a
not-found library (e.g. ``Xxx_ROOT_DIR``). For the same reason, mark
-most cache options as advanced.
+most cache options as advanced. For packages which provide both debug
+and release binaries, it is common to create cache variables with a
+``_LIBRARY_<CONFIG>`` suffix, such as ``Foo_LIBRARY_RELEASE`` and
+``Foo_LIBRARY_DEBUG``.
While these are the standard variable names, you should provide
backwards compatibility for any old names that were actually in use.
@@ -1049,6 +1052,42 @@ not any of its dependencies. Instead, those dependencies should also be
targets, and CMake should be told that they are dependencies of this target.
CMake will then combine all the necessary information automatically.
+If the library is available with multiple configurations, the
+:prop_tgt:`IMPORTED_CONFIGURATIONS` target property should also be
+populated:
+
+.. code-block:: cmake
+
+ if(Foo_FOUND)
+ if (NOT TARGET Foo::Foo)
+ add_library(Foo::Foo UNKNOWN IMPORTED)
+ endif()
+ if (Foo_LIBRARY_RELEASE)
+ set_property(TARGET Foo::Foo APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS RELEASE
+ )
+ set_target_properties(Foo::Foo PROPERTIES
+ IMPORTED_LOCATION_RELEASE "${Foo_LIBRARY_RELEASE}"
+ )
+ endif()
+ if (Foo_LIBRARY_DEBUG)
+ set_property(TARGET Foo::Foo APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS DEBUG
+ )
+ set_target_properties(Foo::Foo PROPERTIES
+ IMPORTED_LOCATION_DEBUG "${Foo_LIBRARY_DEBUG}"
+ )
+ endif()
+ set_target_properties(Foo::Foo PROPERTIES
+ INTERFACE_COMPILE_OPTIONS "${PC_Foo_CFLAGS_OTHER}"
+ INTERFACE_INCLUDE_DIRECTORIES "${Foo_INCLUDE_DIR}"
+ )
+ endif()
+
+The ``RELEASE`` variant should be listed first in the property
+so that that variant is chosen if the user uses a configuration which is
+not an exact match for any listed ``IMPORTED_CONFIGURATIONS``.
+
We should also provide some information about the package, such as where to
download it.