summaryrefslogtreecommitdiff
path: root/Help/command/cmake_minimum_required.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Help/command/cmake_minimum_required.rst')
-rw-r--r--Help/command/cmake_minimum_required.rst23
1 files changed, 15 insertions, 8 deletions
diff --git a/Help/command/cmake_minimum_required.rst b/Help/command/cmake_minimum_required.rst
index c3b3e7370..d15977049 100644
--- a/Help/command/cmake_minimum_required.rst
+++ b/Help/command/cmake_minimum_required.rst
@@ -5,21 +5,21 @@ Require a minimum version of cmake.
.. code-block:: cmake
- cmake_minimum_required(VERSION <min>[...<max>] [FATAL_ERROR])
+ cmake_minimum_required(VERSION <min>[...<policy_max>] [FATAL_ERROR])
.. versionadded:: 3.12
- The optional ``<max>`` version.
+ The optional ``<policy_max>`` version.
Sets the minimum required version of cmake for a project.
Also updates the policy settings as explained below.
-``<min>`` and the optional ``<max>`` are each CMake versions of the form
-``major.minor[.patch[.tweak]]``, and the ``...`` is literal.
+``<min>`` and the optional ``<policy_max>`` are each CMake versions of the
+form ``major.minor[.patch[.tweak]]``, and the ``...`` is literal.
If the running version of CMake is lower than the ``<min>`` required
version it will stop processing the project and report an error.
-The optional ``<max>`` version, if specified, must be at least the
-``<min>`` version and affects policy settings as described below.
+The optional ``<policy_max>`` version, if specified, must be at least the
+``<min>`` version and affects policy settings as described in `Policy Settings`_.
If the running version of CMake is older than 3.12, the extra ``...``
dots will be seen as version component separators, resulting in the
``...<max>`` part being ignored and preserving the pre-3.12 behavior
@@ -40,8 +40,15 @@ with an error instead of just a warning.
they may affect. See also policy :policy:`CMP0000`.
Calling ``cmake_minimum_required()`` inside a :command:`function`
- limits some effects to the function scope when invoked. Such calls
- should not be made with the intention of having global effects.
+ limits some effects to the function scope when invoked. For example,
+ the :variable:`CMAKE_MINIMUM_REQUIRED_VERSION` variable won't be set
+ in the calling scope. Functions do not introduce their own policy
+ scope though, so policy settings of the caller *will* be affected
+ (see below). Due to this mix of things that do and do not affect the
+ calling scope, calling ``cmake_minimum_required()`` inside a function
+ is generally discouraged.
+
+.. _`Policy Settings`:
Policy Settings
^^^^^^^^^^^^^^^