summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2018-10-02 09:09:45 (GMT)
committerMarc Chevrier <marc.chevrier@gmail.com>2018-10-02 09:09:45 (GMT)
commit63c9356544ccd1471e3c428f21662420c0ceb00b (patch)
tree87a9c6a0a8fb3a953312157b079b047973b79ae0 /Modules
parent44de3428597671228c95939c4b509ebaa24f00fe (diff)
downloadCMake-63c9356544ccd1471e3c428f21662420c0ceb00b.zip
CMake-63c9356544ccd1471e3c428f21662420c0ceb00b.tar.gz
CMake-63c9356544ccd1471e3c428f21662420c0ceb00b.tar.bz2
FindPython*: fix erroneous handling of virtual environments
fixes: #18408
Diffstat (limited to 'Modules')
-rw-r--r--Modules/FindPython.cmake6
-rw-r--r--Modules/FindPython/Support.cmake26
-rw-r--r--Modules/FindPython2.cmake6
-rw-r--r--Modules/FindPython3.cmake6
4 files changed, 33 insertions, 11 deletions
diff --git a/Modules/FindPython.cmake b/Modules/FindPython.cmake
index 0bf0b4f..8645a0d 100644
--- a/Modules/FindPython.cmake
+++ b/Modules/FindPython.cmake
@@ -135,6 +135,12 @@ Hints
Value ``ONLY`` is not supported so ``FIRST`` will be used instead.
+.. note::
+
+ If a Python virtual environment is configured, set variable
+ ``Python_FIND_REGISTRY`` (Windows) or ``CMAKE_FIND_FRAMEWORK`` (macOS) with
+ value ``LAST`` or ``NEVER`` to select it preferably.
+
Commands
^^^^^^^^
diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake
index 1834591..a8a73a7 100644
--- a/Modules/FindPython/Support.cmake
+++ b/Modules/FindPython/Support.cmake
@@ -355,20 +355,23 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}
NAMES_PER_DIR
HINTS ${_${_PYTHON_PREFIX}_HINTS}
- PATH_SUFFIXES bin
+ PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH)
# try using standard paths.
- # NAMES_PER_DIR is not defined on purpose to have a chance to find
- # expected version.
- # For example, typical systems have 'python' for version 2.* and 'python3'
- # for version 3.*. So looking for names per dir will find, potentially,
- # systematically 'python' (i.e. version 2) even if version 3 is searched.
- find_program (${_PYTHON_PREFIX}_EXECUTABLE
- NAMES python${_${_PYTHON_PREFIX}_VERSION}
- python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}
- python
- ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES})
+ if (WIN32)
+ find_program (${_PYTHON_PREFIX}_EXECUTABLE
+ NAMES python${_${_PYTHON_PREFIX}_VERSION}
+ python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}
+ python
+ ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}
+ NAMES_PER_DIR)
+ else()
+ find_program (${_PYTHON_PREFIX}_EXECUTABLE
+ NAMES python${_${_PYTHON_PREFIX}_VERSION}
+ python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}
+ NAMES_PER_DIR)
+ endif()
# Apple frameworks handling
if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST")
@@ -413,6 +416,7 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
NAMES python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}
python
${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}
+ NAMES_PER_DIR
HINTS ${_${_PYTHON_PREFIX}_HINTS}
PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
NO_SYSTEM_ENVIRONMENT_PATH
diff --git a/Modules/FindPython2.cmake b/Modules/FindPython2.cmake
index 2735a25..998e992 100644
--- a/Modules/FindPython2.cmake
+++ b/Modules/FindPython2.cmake
@@ -136,6 +136,12 @@ Hints
Value ``ONLY`` is not supported so ``FIRST`` will be used instead.
+.. note::
+
+ If a Python virtual environment is configured, set variable
+ ``Python_FIND_REGISTRY`` (Windows) or ``CMAKE_FIND_FRAMEWORK`` (macOS) with
+ value ``LAST`` or ``NEVER`` to select it preferably.
+
Commands
^^^^^^^^
diff --git a/Modules/FindPython3.cmake b/Modules/FindPython3.cmake
index ed7e1a3..2176f3f 100644
--- a/Modules/FindPython3.cmake
+++ b/Modules/FindPython3.cmake
@@ -136,6 +136,12 @@ Hints
Value ``ONLY`` is not supported so ``FIRST`` will be used instead.
+.. note::
+
+ If a Python virtual environment is configured, set variable
+ ``Python_FIND_REGISTRY`` (Windows) or ``CMAKE_FIND_FRAMEWORK`` (macOS) with
+ value ``LAST`` or ``NEVER`` to select it preferably.
+
Commands
^^^^^^^^