summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBjörn Ricks <bjoern.ricks@intevation.de>2011-07-14 09:43:47 (GMT)
committerBjörn Ricks <bjoern.ricks@intevation.de>2011-08-23 07:52:02 (GMT)
commit4fd1e28495e09af154f361602d30a0c5fc998ff4 (patch)
treeab7b03f7a2bae9016c8e0a47d9a5d7d3d3a196ae /Modules
parent20980ef56a847fec7922983257fd5be467b689bd (diff)
downloadCMake-4fd1e28495e09af154f361602d30a0c5fc998ff4.zip
CMake-4fd1e28495e09af154f361602d30a0c5fc998ff4.tar.gz
CMake-4fd1e28495e09af154f361602d30a0c5fc998ff4.tar.bz2
Determine python version
Use PYTHON_EXECUTABLE to determine PYTHON_VERSION_STRING, PYTHON_VERSION_MINOR, PYTHON_VERSION_MAJOR and PYTHON_VERSION_PATCH
Diffstat (limited to 'Modules')
-rw-r--r--Modules/FindPythonInterp.cmake7
1 files changed, 7 insertions, 0 deletions
diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake
index 871d666..934602d 100644
--- a/Modules/FindPythonInterp.cmake
+++ b/Modules/FindPythonInterp.cmake
@@ -43,6 +43,13 @@ if(NOT PYTHON_EXECUTABLE)
endforeach()
endif()
+if(PYTHON_EXECUTABLE)
+ execute_process(COMMAND "${PYTHON_EXECUTABLE}" --version ERROR_VARIABLE _VERSION OUTPUT_QUIET ERROR_STRIP_TRAILING_WHITESPACE)
+ string(REPLACE "Python " "" PYTHON_VERSION_STRING "${_VERSION}")
+ string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" PYTHON_VERSION_MAJOR "${PYTHON_VERSION_STRING}")
+ string(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+.*" "\\1" PYTHON_VERSION_MINOR "${PYTHON_VERSION_STRING}")
+ string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" PYTHON_VERSION_PATCH "${PYTHON_VERSION_STRING}")
+endif()
# handle the QUIETLY and REQUIRED arguments and set PYTHONINTERP_FOUND to TRUE if
# all listed variables are TRUE