summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2019-05-21 16:10:43 +0200
committerMarc Chevrier <marc.chevrier@gmail.com>2019-05-21 16:13:27 +0200
commit8517b549f44eb41c93eb1c448de176ad4172f083 (patch)
tree5b04ff46e29299b416c85b291b93f72a328f6316 /Modules
parent9f205acefe256ac9707cd500ea1d421916f013cd (diff)
downloadcmake-8517b549f44eb41c93eb1c448de176ad4172f083.tar.gz
FindPython: Add policy to manage lookup stratgey default.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/FindPython.cmake4
-rw-r--r--Modules/FindPython/Support.cmake14
-rw-r--r--Modules/FindPython2.cmake4
-rw-r--r--Modules/FindPython3.cmake4
4 files changed, 21 insertions, 5 deletions
diff --git a/Modules/FindPython.cmake b/Modules/FindPython.cmake
index d368ecce9b..59c286db98 100644
--- a/Modules/FindPython.cmake
+++ b/Modules/FindPython.cmake
@@ -144,9 +144,11 @@ Hints
* ``VERSION``: Try to find the most recent version in all specified
locations.
- This is the default.
+ This is the default if policy :policy:`CMP0094` is undefined or set to
+ ``OLD``.
* ``LOCATION``: Stops lookup as soon as a version satisfying version
constraints is founded.
+ This is the default if policy :policy:`CMP0094` is set to ``NEW``.
``Python_FIND_REGISTRY``
On Windows the ``Python_FIND_REGISTRY`` variable determine the order
diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake
index 4ba0b0fc18..bb2f60d945 100644
--- a/Modules/FindPython/Support.cmake
+++ b/Modules/FindPython/Support.cmake
@@ -5,8 +5,14 @@
# This file is a "template" file used by various FindPython modules.
#
+cmake_policy (GET CMP0094 _${_PYTHON_PREFIX}_LOOKUP_POLICY)
+
cmake_policy (VERSION 3.7)
+if (_${_PYTHON_PREFIX}_LOOKUP_POLICY)
+ cmake_policy (SET CMP0094 ${_${_PYTHON_PREFIX}_LOOKUP_POLICY})
+endif()
+
#
# Initial configuration
#
@@ -316,13 +322,17 @@ if (${_PYTHON_PREFIX}_FIND_VERSION_COUNT GREATER 1)
endif()
# Define lookup strategy
-set (_${_PYTHON_PREFIX}_FIND_STRATEGY "VERSION")
+if (_${_PYTHON_PREFIX}_LOOKUP_POLICY STREQUAL "NEW")
+ set (_${_PYTHON_PREFIX}_FIND_STRATEGY "LOCATION")
+else()
+ set (_${_PYTHON_PREFIX}_FIND_STRATEGY "VERSION")
+endif()
if (DEFINED ${_PYTHON_PREFIX}_FIND_STRATEGY)
if (NOT ${_PYTHON_PREFIX}_FIND_STRATEGY MATCHES "^(VERSION|LOCATION)$")
message (AUTHOR_WARNING "Find${_PYTHON_PREFIX}: ${${_PYTHON_PREFIX}_FIND_STRATEGY}: invalid value for '${_PYTHON_PREFIX}_FIND_STRATEGY'. 'VERSION' or 'LOCATION' expected.")
set (_${_PYTHON_PREFIX}_FIND_STRATEGY "VERSION")
else()
- set (_${_PYTHON_PREFIX}_FIND_STRATEGY "${${_PYTHON_PREFIX}_FIND_STRATEGY}")
+ set (_${_PYTHON_PREFIX}_FIND_STRATEGY "${${_PYTHON_PREFIX}_FIND_STRATEGY}")
endif()
endif()
diff --git a/Modules/FindPython2.cmake b/Modules/FindPython2.cmake
index eea4d292b2..8a633e0d00 100644
--- a/Modules/FindPython2.cmake
+++ b/Modules/FindPython2.cmake
@@ -145,9 +145,11 @@ Hints
* ``VERSION``: Try to find the most recent version in all specified
locations.
- This is the default.
+ This is the default if policy :policy:`CMP0094` is undefined or set to
+ ``OLD``.
* ``LOCATION``: Stops lookup as soon as a version satisfying version
constraints is founded.
+ This is the default if policy :policy:`CMP0094` is set to ``NEW``.
``Python2_FIND_REGISTRY``
On Windows the ``Python2_FIND_REGISTRY`` variable determine the order
diff --git a/Modules/FindPython3.cmake b/Modules/FindPython3.cmake
index 5e42732c10..2867326a65 100644
--- a/Modules/FindPython3.cmake
+++ b/Modules/FindPython3.cmake
@@ -145,9 +145,11 @@ Hints
* ``VERSION``: Try to find the most recent version in all specified
locations.
- This is the default.
+ This is the default if policy :policy:`CMP0094` is undefined or set to
+ ``OLD``.
* ``LOCATION``: Stops lookup as soon as a version satisfying version
constraints is founded.
+ This is the default if policy :policy:`CMP0094` is set to ``NEW``.
``Python3_FIND_REGISTRY``
On Windows the ``Python3_FIND_REGISTRY`` variable determine the order