diff --git a/Help/command/option.rst b/Help/command/option.rst index 464ad441a9..1f5bd3fbb7 100644 --- a/Help/command/option.rst +++ b/Help/command/option.rst @@ -16,3 +16,9 @@ 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. diff --git a/Help/policy/CMP0127.rst b/Help/policy/CMP0127.rst index 3de4f5ea92..798140b77c 100644 --- a/Help/policy/CMP0127.rst +++ b/Help/policy/CMP0127.rst @@ -5,7 +5,7 @@ CMP0127 :command:`cmake_dependent_option` supports full :ref:`Condition Syntax`. -The ```` parameter accepts a :ref:`semicolon-separated list `` parameter accepts a :ref:`semicolon-separated list ` of conditions. CMake 3.21 and lower evaluates each ``condition`` as ``if(${condition})``, which does not properly handle conditions with nested paren groups. CMake 3.22 and above instead prefer diff --git a/Modules/CMakeDependentOption.cmake b/Modules/CMakeDependentOption.cmake index acafd56d39..53a6a64ecd 100644 --- a/Modules/CMakeDependentOption.cmake +++ b/Modules/CMakeDependentOption.cmake @@ -5,61 +5,199 @@ CMakeDependentOption -------------------- -Macro to provide an option dependent on other options. +This module provides a command to define boolean options whose availability and +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. -This macro presents an option to the user only if a set of other -conditions are true. +Commands +^^^^^^^^ .. command:: cmake_dependent_option + Provides a boolean option that depends on a set of conditions: + .. code-block:: cmake - cmake_dependent_option(