summaryrefslogtreecommitdiffstats
path: root/Modules/FindPythonInterp.cmake
diff options
context:
space:
mode:
authorRolf Eike Beer <eike@sf-mail.de>2013-08-31 15:46:44 (GMT)
committerRolf Eike Beer <eike@sf-mail.de>2013-08-31 15:46:44 (GMT)
commitafd4f7f0428f48c6a01eb828dd07e057048edc49 (patch)
treed4d2df3bcdfc7e811ec49fa2a8cc0d2a39d127ba /Modules/FindPythonInterp.cmake
parent81aaad0c7357b50770284b7d87d04cedf8bc4eae (diff)
downloadCMake-afd4f7f0428f48c6a01eb828dd07e057048edc49.zip
CMake-afd4f7f0428f48c6a01eb828dd07e057048edc49.tar.gz
CMake-afd4f7f0428f48c6a01eb828dd07e057048edc49.tar.bz2
FindPython*: simplify version selection
CMake already provides the version components split into variables, no need to split them again.
Diffstat (limited to 'Modules/FindPythonInterp.cmake')
-rw-r--r--Modules/FindPythonInterp.cmake18
1 files changed, 10 insertions, 8 deletions
diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake
index 7fb65b8..b6b7897 100644
--- a/Modules/FindPythonInterp.cmake
+++ b/Modules/FindPythonInterp.cmake
@@ -36,28 +36,30 @@ set(_PYTHON2_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0)
set(_PYTHON3_VERSIONS 3.3 3.2 3.1 3.0)
if(PythonInterp_FIND_VERSION)
- if(PythonInterp_FIND_VERSION MATCHES "^[0-9]+\\.[0-9]+(\\.[0-9]+.*)?$")
- string(REGEX REPLACE "^([0-9]+\\.[0-9]+).*" "\\1" _PYTHON_FIND_MAJ_MIN "${PythonInterp_FIND_VERSION}")
- string(REGEX REPLACE "^([0-9]+).*" "\\1" _PYTHON_FIND_MAJ "${_PYTHON_FIND_MAJ_MIN}")
- list(APPEND _Python_NAMES python${_PYTHON_FIND_MAJ_MIN} python${_PYTHON_FIND_MAJ})
+ if(PythonInterp_FIND_VERSION_COUNT GREATER 1)
+ set(_PYTHON_FIND_MAJ_MIN "${PythonInterp_FIND_VERSION_MAJOR}.${PythonInterp_FIND_VERSION_MINOR}")
+ list(APPEND _Python_NAMES
+ python${_PYTHON_FIND_MAJ_MIN}
+ python${PythonInterp_FIND_VERSION_MAJOR})
unset(_PYTHON_FIND_OTHER_VERSIONS)
if(NOT PythonInterp_FIND_VERSION_EXACT)
- foreach(_PYTHON_V ${_PYTHON${_PYTHON_FIND_MAJ}_VERSIONS})
+ foreach(_PYTHON_V ${_PYTHON${PythonInterp_FIND_VERSION_MAJOR}_VERSIONS})
if(NOT _PYTHON_V VERSION_LESS _PYTHON_FIND_MAJ_MIN)
list(APPEND _PYTHON_FIND_OTHER_VERSIONS ${_PYTHON_V})
endif()
endforeach()
endif()
unset(_PYTHON_FIND_MAJ_MIN)
- unset(_PYTHON_FIND_MAJ)
else()
- list(APPEND _Python_NAMES python${PythonInterp_FIND_VERSION})
- set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON${PythonInterp_FIND_VERSION}_VERSIONS})
+ list(APPEND _Python_NAMES python${PythonInterp_FIND_VERSION_MAJOR})
+ set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON${PythonInterp_FIND_VERSION_MAJOR}_VERSIONS})
endif()
else()
set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON3_VERSIONS} ${_PYTHON2_VERSIONS} ${_PYTHON1_VERSIONS})
endif()
+message(STATUS "names ${_Python_NAMES}")
+message(STATUS "other versions ${_PYTHON_FIND_OTHER_VERSIONS}")
list(APPEND _Python_NAMES python)
# Search for the current active python version first