Merge topic 'more-python-version'

bde7b5a FindPythonInterp: try harder to get a version number
This commit is contained in:
David Cole 2012-02-01 14:50:03 -05:00 committed by CMake Topic Stage
commit 29cddc60cd
1 changed files with 15 additions and 2 deletions

View File

@ -88,8 +88,19 @@ endif()
# determine python version string
if(PYTHON_EXECUTABLE)
execute_process(COMMAND "${PYTHON_EXECUTABLE}" --version ERROR_VARIABLE _VERSION OUTPUT_QUIET ERROR_STRIP_TRAILING_WHITESPACE)
if(_VERSION MATCHES "^Python [0-9]+\\.[0-9]+.*")
execute_process(COMMAND "${PYTHON_EXECUTABLE}" --version
ERROR_VARIABLE _VERSION
RESULT_VARIABLE _PYTHON_VERSION_RESULT
OUTPUT_QUIET
ERROR_STRIP_TRAILING_WHITESPACE)
if(_PYTHON_VERSION_RESULT)
execute_process(COMMAND "${PYTHON_EXECUTABLE}" -V
ERROR_VARIABLE _VERSION
RESULT_VARIABLE _PYTHON_VERSION_RESULT
OUTPUT_QUIET
ERROR_STRIP_TRAILING_WHITESPACE)
endif(_PYTHON_VERSION_RESULT)
if(NOT _PYTHON_VERSION_RESULT AND _VERSION MATCHES "^Python [0-9]+\\.[0-9]+.*")
string(REPLACE "Python " "" PYTHON_VERSION_STRING "${_VERSION}")
string(REGEX REPLACE "^([0-9]+)\\.[0-9]+.*" "\\1" PYTHON_VERSION_MAJOR "${PYTHON_VERSION_STRING}")
string(REGEX REPLACE "^[0-9]+\\.([0-9])+.*" "\\1" PYTHON_VERSION_MINOR "${PYTHON_VERSION_STRING}")
@ -97,6 +108,8 @@ if(PYTHON_EXECUTABLE)
string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" PYTHON_VERSION_PATCH "${PYTHON_VERSION_STRING}")
endif()
endif()
unset(_PYTHON_VERSION_RESULT)
unset(_VERSION)
endif(PYTHON_EXECUTABLE)
# handle the QUIETLY and REQUIRED arguments and set PYTHONINTERP_FOUND to TRUE if