Merge topic 'patch-CMakeDependentOption'

f70f972562 CMakeDependentOption: Sync documentation

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10768
This commit is contained in:
Brad King
2025-05-13 14:31:12 +00:00
committed by Kitware Robot
3 changed files with 19 additions and 14 deletions
+16 -8
View File
@@ -10,9 +10,17 @@ default values depend on specified conditions or other options. This helps
maintain a clean configuration interface by only displaying options that are
relevant to the current settings.
Load this module in a CMake project with:
.. code-block:: cmake
include(CMakeDependentOption)
Commands
^^^^^^^^
This module provides the following command:
.. command:: cmake_dependent_option
Provides a boolean option that depends on a set of conditions:
@@ -21,9 +29,9 @@ Commands
cmake_dependent_option(<variable> <help> <value> <condition> <else-value>)
This macro creates a boolean ``<variable>`` and makes it available to the user
in the GUI (such as :manual:`cmake-gui(1)` or :manual:`ccmake(1)`), if a set
of conditions evaluates to boolean true.
This command creates a boolean ``<variable>`` and makes it available to the
user in the GUI (such as :manual:`cmake-gui(1)` or :manual:`ccmake(1)`), if
a set of conditions evaluates to boolean true.
The arguments are:
@@ -83,7 +91,7 @@ Example: Basic Usage
Using this module in a project to conditionally set an option:
.. code-block:: cmake
:caption: CMakeLists.txt
:caption: ``CMakeLists.txt``
include(CMakeDependentOption)
@@ -96,7 +104,7 @@ Extending the previous example, this demonstrates how the module allows
user-configurable options based on a condition during the configuration phase:
.. code-block:: cmake
:caption: CMakeLists.txt
:caption: ``CMakeLists.txt``
include(CMakeDependentOption)
@@ -151,7 +159,7 @@ runs, the previous value of ``USE_FOO`` is preserved so that when it becomes
available again, it retains its last set value.
.. code-block:: cmake
:caption: CMakeLists.txt
:caption: ``CMakeLists.txt``
include(CMakeDependentOption)
@@ -168,7 +176,7 @@ in the GUI. The value of ``USE_FOO`` is preserved across configuration runs,
similar to the previous example.
.. code-block:: cmake
:caption: CMakeLists.txt
:caption: ``CMakeLists.txt``
include(CMakeDependentOption)
@@ -178,7 +186,7 @@ Another example demonstrates how an option can be conditionally available based
on the target system:
.. code-block:: cmake
:caption: CMakeLists.txt
:caption: ``CMakeLists.txt``
include(CMakeDependentOption)