Merge topic 'FindPython_versions'
afd4f7f
FindPython*: simplify version selection
This commit is contained in:
commit
1c49ecad36
|
@ -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)
|
set(_PYTHON3_VERSIONS 3.3 3.2 3.1 3.0)
|
||||||
|
|
||||||
if(PythonInterp_FIND_VERSION)
|
if(PythonInterp_FIND_VERSION)
|
||||||
if(PythonInterp_FIND_VERSION MATCHES "^[0-9]+\\.[0-9]+(\\.[0-9]+.*)?$")
|
if(PythonInterp_FIND_VERSION_COUNT GREATER 1)
|
||||||
string(REGEX REPLACE "^([0-9]+\\.[0-9]+).*" "\\1" _PYTHON_FIND_MAJ_MIN "${PythonInterp_FIND_VERSION}")
|
set(_PYTHON_FIND_MAJ_MIN "${PythonInterp_FIND_VERSION_MAJOR}.${PythonInterp_FIND_VERSION_MINOR}")
|
||||||
string(REGEX REPLACE "^([0-9]+).*" "\\1" _PYTHON_FIND_MAJ "${_PYTHON_FIND_MAJ_MIN}")
|
list(APPEND _Python_NAMES
|
||||||
list(APPEND _Python_NAMES python${_PYTHON_FIND_MAJ_MIN} python${_PYTHON_FIND_MAJ})
|
python${_PYTHON_FIND_MAJ_MIN}
|
||||||
|
python${PythonInterp_FIND_VERSION_MAJOR})
|
||||||
unset(_PYTHON_FIND_OTHER_VERSIONS)
|
unset(_PYTHON_FIND_OTHER_VERSIONS)
|
||||||
if(NOT PythonInterp_FIND_VERSION_EXACT)
|
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)
|
if(NOT _PYTHON_V VERSION_LESS _PYTHON_FIND_MAJ_MIN)
|
||||||
list(APPEND _PYTHON_FIND_OTHER_VERSIONS ${_PYTHON_V})
|
list(APPEND _PYTHON_FIND_OTHER_VERSIONS ${_PYTHON_V})
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
unset(_PYTHON_FIND_MAJ_MIN)
|
unset(_PYTHON_FIND_MAJ_MIN)
|
||||||
unset(_PYTHON_FIND_MAJ)
|
|
||||||
else()
|
else()
|
||||||
list(APPEND _Python_NAMES python${PythonInterp_FIND_VERSION})
|
list(APPEND _Python_NAMES python${PythonInterp_FIND_VERSION_MAJOR})
|
||||||
set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON${PythonInterp_FIND_VERSION}_VERSIONS})
|
set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON${PythonInterp_FIND_VERSION_MAJOR}_VERSIONS})
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON3_VERSIONS} ${_PYTHON2_VERSIONS} ${_PYTHON1_VERSIONS})
|
set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON3_VERSIONS} ${_PYTHON2_VERSIONS} ${_PYTHON1_VERSIONS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
message(STATUS "names ${_Python_NAMES}")
|
||||||
|
message(STATUS "other versions ${_PYTHON_FIND_OTHER_VERSIONS}")
|
||||||
list(APPEND _Python_NAMES python)
|
list(APPEND _Python_NAMES python)
|
||||||
|
|
||||||
# Search for the current active python version first
|
# Search for the current active python version first
|
||||||
|
|
|
@ -41,9 +41,8 @@ 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)
|
set(_PYTHON3_VERSIONS 3.3 3.2 3.1 3.0)
|
||||||
|
|
||||||
if(PythonLibs_FIND_VERSION)
|
if(PythonLibs_FIND_VERSION)
|
||||||
if(PythonLibs_FIND_VERSION MATCHES "^[0-9]+\\.[0-9]+(\\.[0-9]+.*)?$")
|
if(PythonLibs_FIND_VERSION_COUNT GREATER 1)
|
||||||
string(REGEX REPLACE "^([0-9]+\\.[0-9]+).*" "\\1" _PYTHON_FIND_MAJ_MIN "${PythonLibs_FIND_VERSION}")
|
set(_PYTHON_FIND_MAJ_MIN "${PythonLibs_FIND_VERSION_MAJOR}.${PythonLibs_FIND_VERSION_MINOR}")
|
||||||
string(REGEX REPLACE "^([0-9]+).*" "\\1" _PYTHON_FIND_MAJ "${_PYTHON_FIND_MAJ_MIN}")
|
|
||||||
unset(_PYTHON_FIND_OTHER_VERSIONS)
|
unset(_PYTHON_FIND_OTHER_VERSIONS)
|
||||||
if(PythonLibs_FIND_VERSION_EXACT)
|
if(PythonLibs_FIND_VERSION_EXACT)
|
||||||
if(_PYTHON_FIND_MAJ_MIN STREQUAL PythonLibs_FIND_VERSION)
|
if(_PYTHON_FIND_MAJ_MIN STREQUAL PythonLibs_FIND_VERSION)
|
||||||
|
@ -52,16 +51,15 @@ if(PythonLibs_FIND_VERSION)
|
||||||
set(_PYTHON_FIND_OTHER_VERSIONS "${PythonLibs_FIND_VERSION}" "${_PYTHON_FIND_MAJ_MIN}")
|
set(_PYTHON_FIND_OTHER_VERSIONS "${PythonLibs_FIND_VERSION}" "${_PYTHON_FIND_MAJ_MIN}")
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
foreach(_PYTHON_V ${_PYTHON${_PYTHON_FIND_MAJ}_VERSIONS})
|
foreach(_PYTHON_V ${_PYTHON${PythonLibs_FIND_VERSION_MAJOR}_VERSIONS})
|
||||||
if(NOT _PYTHON_V VERSION_LESS _PYTHON_FIND_MAJ_MIN)
|
if(NOT _PYTHON_V VERSION_LESS _PYTHON_FIND_MAJ_MIN)
|
||||||
list(APPEND _PYTHON_FIND_OTHER_VERSIONS ${_PYTHON_V})
|
list(APPEND _PYTHON_FIND_OTHER_VERSIONS ${_PYTHON_V})
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
unset(_PYTHON_FIND_MAJ_MIN)
|
unset(_PYTHON_FIND_MAJ_MIN)
|
||||||
unset(_PYTHON_FIND_MAJ)
|
|
||||||
else()
|
else()
|
||||||
set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON${PythonLibs_FIND_VERSION}_VERSIONS})
|
set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON${PythonLibs_FIND_VERSION_MAJOR}_VERSIONS})
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON3_VERSIONS} ${_PYTHON2_VERSIONS} ${_PYTHON1_VERSIONS})
|
set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON3_VERSIONS} ${_PYTHON2_VERSIONS} ${_PYTHON1_VERSIONS})
|
||||||
|
|
Loading…
Reference in New Issue