diff options
author | David Cole <david.cole@kitware.com> | 2012-02-01 19:50:03 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2012-02-01 19:50:03 (GMT) |
commit | 29cddc60cda2f1cf94f2753cfcca3c9c7e7959a5 (patch) | |
tree | a122c9383e1bd861cfe5ff227adfa16c3625da7a | |
parent | 79b7fe9d5e7be36b5c9ed5cf3178d4387cdd2ed1 (diff) | |
parent | bde7b5aafd5ab1ff180c900b0e473fc85bafa724 (diff) | |
download | CMake-29cddc60cda2f1cf94f2753cfcca3c9c7e7959a5.zip CMake-29cddc60cda2f1cf94f2753cfcca3c9c7e7959a5.tar.gz CMake-29cddc60cda2f1cf94f2753cfcca3c9c7e7959a5.tar.bz2 |
Merge topic 'more-python-version'
bde7b5a FindPythonInterp: try harder to get a version number
-rw-r--r-- | Modules/FindPythonInterp.cmake | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake index d5a2a5e..5c1d56b 100644 --- a/Modules/FindPythonInterp.cmake +++ b/Modules/FindPythonInterp.cmake @@ -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 |