Просмотр исходного кода

CMakeDependentOption: Sync documentation

- Added intro code block with include() showing how to load this module.
- Used "command" instead of "macro".
- Removed duplicate mention of CMakeDependentOption module in the
  option() documentation.
- Synced captions in examples.
Peter Kokot 9 месяцев назад
Родитель
Сommit
f70f972562
3 измененных файлов с 19 добавлено и 14 удалено
  1. 2 5
      Help/command/option.rst
  2. 1 1
      Help/release/3.22.rst
  3. 16 8
      Modules/CMakeDependentOption.cmake

+ 2 - 5
Help/command/option.rst

@@ -11,14 +11,11 @@ If no initial ``<value>`` is provided, boolean ``OFF`` is the default value.
 If ``<variable>`` is already set as a normal or cache variable,
 then the command does nothing (see policy :policy:`CMP0077`).
 
-For options that depend on the values of other options, see
-the module help for :module:`CMakeDependentOption`.
-
 In CMake project mode, a boolean cache variable is created with the option
 value. In CMake script mode, a boolean variable is set with the option value.
 
 See Also
 ^^^^^^^^
 
-* The :module:`CMakeDependentOption` module to specify dependent boolean options
-  based on a set of conditions.
+* The :module:`CMakeDependentOption` module to specify boolean options that
+  depend on the values of other options or a set of conditions.

+ 1 - 1
Help/release/3.22.rst

@@ -58,7 +58,7 @@ Modules
 -------
 
 * The :module:`CMakeDependentOption` module :command:`cmake_dependent_option`
-  macro now supports full :ref:`Condition Syntax`.
+  command now supports full :ref:`Condition Syntax`.
   See policy :policy:`CMP0127`.
 
 * The :module:`FetchContent` module now passes through the

+ 16 - 8
Modules/CMakeDependentOption.cmake

@@ -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)