1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-16 05:26:58 +08:00

Help: Clarify calling cmake_minimum_required() inside a function

Fixes: #21519
This commit is contained in:
Craig Scott
2021-05-15 15:26:01 +10:00
parent 639a6bd4c7
commit b00a171b2b
2 changed files with 9 additions and 3 deletions

View File

@@ -40,8 +40,13 @@ with an error instead of just a warning.
they may affect. See also policy :policy:`CMP0000`. they may affect. See also policy :policy:`CMP0000`.
Calling ``cmake_minimum_required()`` inside a :command:`function` Calling ``cmake_minimum_required()`` inside a :command:`function`
limits some effects to the function scope when invoked. Such calls limits some effects to the function scope when invoked. For example,
should not be made with the intention of having global effects. 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`:

View File

@@ -2,4 +2,5 @@ CMAKE_MINIMUM_REQUIRED_VERSION
------------------------------ ------------------------------
The ``<min>`` version of CMake given to the most recent call to the The ``<min>`` version of CMake given to the most recent call to the
:command:`cmake_minimum_required(VERSION)` command. :command:`cmake_minimum_required(VERSION)` command in the current
variable scope or any parent variable scope.