diff options
author | Brad King <brad.king@kitware.com> | 2019-01-28 12:58:36 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-01-28 12:58:45 (GMT) |
commit | f411e936be6c5d0070c67aeb3baea150a01024a1 (patch) | |
tree | 2b0f449fc09fb0fff3b1e07ce8384e12affa9146 | |
parent | f832f15509ae269d236c0c7a5e06808b78fdaba2 (diff) | |
parent | 08dee696b5831a8cba0a70df5e6b072f91d0c6f8 (diff) | |
download | CMake-f411e936be6c5d0070c67aeb3baea150a01024a1.zip CMake-f411e936be6c5d0070c67aeb3baea150a01024a1.tar.gz CMake-f411e936be6c5d0070c67aeb3baea150a01024a1.tar.bz2 |
Merge topic 'FindPythonInterp-version-fix'
08dee696b5 FindPythonInterp: Do not assume any version if test script fails
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2835
-rw-r--r-- | Modules/FindPythonInterp.cmake | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake index d1f7b31..da33301 100644 --- a/Modules/FindPythonInterp.cmake +++ b/Modules/FindPythonInterp.cmake @@ -130,7 +130,9 @@ if(PYTHON_EXECUTABLE) endif() else() # sys.version predates sys.version_info, so use that - execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c "import sys; sys.stdout.write(sys.version)" + # sys.version was first documented for Python 1.5, so assume version 1.4 + # if retrieving sys.version fails. + execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c "try: import sys; sys.stdout.write(sys.version)\nexcept: sys.stdout.write(\"1.4.0\")" OUTPUT_VARIABLE _VERSION RESULT_VARIABLE _PYTHON_VERSION_RESULT ERROR_QUIET) @@ -144,12 +146,10 @@ if(PYTHON_EXECUTABLE) set(PYTHON_VERSION_PATCH "0") endif() else() - # sys.version was first documented for Python 1.5, so assume - # this is older. - set(PYTHON_VERSION_STRING "1.4") - set(PYTHON_VERSION_MAJOR "1") - set(PYTHON_VERSION_MINOR "4") - set(PYTHON_VERSION_PATCH "0") + unset(PYTHON_VERSION_STRING) + unset(PYTHON_VERSION_MAJOR) + unset(PYTHON_VERSION_MINOR) + unset(PYTHON_VERSION_PATCH) endif() endif() unset(_PYTHON_VERSION_RESULT) |