diff --git a/Help/command/option.rst b/Help/command/option.rst index 1f5bd3fbb7..b939a2d0c6 100644 --- a/Help/command/option.rst +++ b/Help/command/option.rst @@ -11,14 +11,11 @@ If no initial ```` is provided, boolean ``OFF`` is the default value. If ```` 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. diff --git a/Help/release/3.22.rst b/Help/release/3.22.rst index 2d060acaf4..efc811536c 100644 --- a/Help/release/3.22.rst +++ b/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 diff --git a/Modules/CMakeDependentOption.cmake b/Modules/CMakeDependentOption.cmake index 73496a4b73..3db05da920 100644 --- a/Modules/CMakeDependentOption.cmake +++ b/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( ) - This macro creates a boolean ```` 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 ```` 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)