mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 05:40:54 -06:00
SelectLibraryConfigurations: Add intro code block
- Added intro code block showing how to include this module. - Used "command" instead of "macro".
This commit is contained in:
@@ -5,11 +5,18 @@
|
|||||||
SelectLibraryConfigurations
|
SelectLibraryConfigurations
|
||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
This module is intended to be used in :ref:`Find Modules` when finding packages
|
This module is intended for use in :ref:`Find Modules` and provides a
|
||||||
that are available with multiple :ref:`Build Configurations`. It provides a
|
command to automatically set library variables when package is available
|
||||||
macro that automatically sets and adjusts library variables. Supported library
|
with multiple :ref:`Build Configurations`.
|
||||||
build configurations are ``Release`` and ``Debug`` as these are the most common
|
|
||||||
ones in such packages.
|
Load it in a CMake find module with:
|
||||||
|
|
||||||
|
.. code-block:: cmake
|
||||||
|
|
||||||
|
include(SelectLibraryConfigurations)
|
||||||
|
|
||||||
|
Supported build configurations are ``Release`` and ``Debug`` as these are
|
||||||
|
the most common ones in such packages.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
@@ -20,13 +27,21 @@ ones in such packages.
|
|||||||
targets provide finer control over linking through the
|
targets provide finer control over linking through the
|
||||||
:prop_tgt:`IMPORTED_CONFIGURATIONS` property.
|
:prop_tgt:`IMPORTED_CONFIGURATIONS` property.
|
||||||
|
|
||||||
|
Commands
|
||||||
|
^^^^^^^^
|
||||||
|
|
||||||
|
This module provides the following command:
|
||||||
|
|
||||||
.. command:: select_library_configurations
|
.. command:: select_library_configurations
|
||||||
|
|
||||||
|
Sets and adjusts library variables based on debug and release build
|
||||||
|
configurations:
|
||||||
|
|
||||||
.. code-block:: cmake
|
.. code-block:: cmake
|
||||||
|
|
||||||
select_library_configurations(<basename>)
|
select_library_configurations(<basename>)
|
||||||
|
|
||||||
This macro is a helper for setting the ``<basename>_LIBRARY`` and
|
This command is a helper for setting the ``<basename>_LIBRARY`` and
|
||||||
``<basename>_LIBRARIES`` result variables when a library might be provided
|
``<basename>_LIBRARIES`` result variables when a library might be provided
|
||||||
with multiple build configurations.
|
with multiple build configurations.
|
||||||
|
|
||||||
@@ -37,20 +52,20 @@ ones in such packages.
|
|||||||
the name of the package as used in the ``Find<PackageName>.cmake`` module
|
the name of the package as used in the ``Find<PackageName>.cmake`` module
|
||||||
filename, or the component name, when find module provides them.
|
filename, or the component name, when find module provides them.
|
||||||
|
|
||||||
Prior to calling this macro the following cache variables should be set in the
|
Prior to calling this command the following cache variables should be set
|
||||||
find module (for example, by the :command:`find_library` command):
|
in the find module (for example, by the :command:`find_library` command):
|
||||||
|
|
||||||
``<basename>_LIBRARY_RELEASE``
|
``<basename>_LIBRARY_RELEASE``
|
||||||
A cache variable storing the full path to the ``Release`` build of the
|
A cache variable storing the full path to the ``Release`` build of the
|
||||||
library. If not set or found, this macro will set its value to
|
library. If not set or found, this command will set its value to
|
||||||
``<basename>_LIBRARY_RELEASE-NOTFOUND``.
|
``<basename>_LIBRARY_RELEASE-NOTFOUND``.
|
||||||
|
|
||||||
``<basename>_LIBRARY_DEBUG``
|
``<basename>_LIBRARY_DEBUG``
|
||||||
A cache variable storing the full path to the ``Debug`` build of the
|
A cache variable storing the full path to the ``Debug`` build of the
|
||||||
library. If not set or found, this macro will set its value to
|
library. If not set or found, this command will set its value to
|
||||||
``<basename>_LIBRARY_DEBUG-NOTFOUND``.
|
``<basename>_LIBRARY_DEBUG-NOTFOUND``.
|
||||||
|
|
||||||
This macro then sets the following local result variables:
|
This command then sets the following local result variables:
|
||||||
|
|
||||||
``<basename>_LIBRARY``
|
``<basename>_LIBRARY``
|
||||||
A result variable that is set to the value of
|
A result variable that is set to the value of
|
||||||
@@ -74,12 +89,11 @@ ones in such packages.
|
|||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
The ``select_library_configurations()`` macro should be called before
|
The ``select_library_configurations()`` command should be called before
|
||||||
handling standard find module arguments with
|
handling standard find module arguments with
|
||||||
:module:`find_package_handle_standard_args()
|
:command:`find_package_handle_standard_args` to ensure that the
|
||||||
<FindPackageHandleStandardArgs>` to ensure that the ``<PackageName>_FOUND``
|
``<PackageName>_FOUND`` result variable is correctly set based on
|
||||||
result variable is correctly set based on ``<basename>_LIBRARY`` or other
|
``<basename>_LIBRARY`` or other related variables.
|
||||||
related variables.
|
|
||||||
|
|
||||||
Examples
|
Examples
|
||||||
^^^^^^^^
|
^^^^^^^^
|
||||||
@@ -88,7 +102,7 @@ Setting library variables based on the build configuration inside a find module
|
|||||||
file:
|
file:
|
||||||
|
|
||||||
.. code-block:: cmake
|
.. code-block:: cmake
|
||||||
:caption: FindFoo.cmake
|
:caption: ``FindFoo.cmake``
|
||||||
|
|
||||||
# Find release and debug build of the library
|
# Find release and debug build of the library
|
||||||
find_library(Foo_LIBRARY_RELEASE ...)
|
find_library(Foo_LIBRARY_RELEASE ...)
|
||||||
@@ -108,7 +122,7 @@ file:
|
|||||||
When find module provides components with multiple build configurations:
|
When find module provides components with multiple build configurations:
|
||||||
|
|
||||||
.. code-block:: cmake
|
.. code-block:: cmake
|
||||||
:caption: FindFoo.cmake
|
:caption: ``FindFoo.cmake``
|
||||||
|
|
||||||
include(SelectLibraryConfigurations)
|
include(SelectLibraryConfigurations)
|
||||||
foreach(component IN LISTS Foo_FIND_COMPONENTS)
|
foreach(component IN LISTS Foo_FIND_COMPONENTS)
|
||||||
@@ -120,7 +134,7 @@ When find module provides components with multiple build configurations:
|
|||||||
A project can then use this find module as follows:
|
A project can then use this find module as follows:
|
||||||
|
|
||||||
.. code-block:: cmake
|
.. code-block:: cmake
|
||||||
:caption: CMakeLists.txt
|
:caption: ``CMakeLists.txt``
|
||||||
|
|
||||||
find_package(Foo)
|
find_package(Foo)
|
||||||
target_link_libraries(project_target PRIVATE ${Foo_LIBRARIES})
|
target_link_libraries(project_target PRIVATE ${Foo_LIBRARIES})
|
||||||
|
|||||||
Reference in New Issue
Block a user