diff options
author | Marcus D. Hanwell <marcus.hanwell@kitware.com> | 2011-01-10 18:44:45 (GMT) |
---|---|---|
committer | Marcus D. Hanwell <marcus.hanwell@kitware.com> | 2011-01-10 18:44:45 (GMT) |
commit | 2d3594b1bbd48d0dc7a071a6806c75c89341e1c5 (patch) | |
tree | 62c365528aaef3e2cb73d22b1c57abe2d349e1d7 /Modules/FindPythonInterp.cmake | |
parent | 6754b26bf0bb69ad6d65249bf4122dbbda446922 (diff) | |
download | CMake-2d3594b1bbd48d0dc7a071a6806c75c89341e1c5.zip CMake-2d3594b1bbd48d0dc7a071a6806c75c89341e1c5.tar.gz CMake-2d3594b1bbd48d0dc7a071a6806c75c89341e1c5.tar.bz2 |
Python additional version support, bug #10279.
Introduced an additional variable, Python_ADDITIONAL_VERSIONS, to both
FindPythonLibs and FindPythonInterp. Changed FindPythonInterp to loop
over versions rather than hardcoding all versions (more like libs).
Diffstat (limited to 'Modules/FindPythonInterp.cmake')
-rw-r--r-- | Modules/FindPythonInterp.cmake | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake index 645ca79..f2c116f 100644 --- a/Modules/FindPythonInterp.cmake +++ b/Modules/FindPythonInterp.cmake @@ -2,8 +2,9 @@ # This module finds if Python interpreter is installed and determines where the # executables are. This code sets the following variables: # -# PYTHONINTERP_FOUND - Was the Python executable found -# PYTHON_EXECUTABLE - path to the Python interpreter +# PYTHONINTERP_FOUND - Was the Python executable found +# PYTHON_EXECUTABLE - path to the Python interpreter +# Python_ADDITIONAL_VERSIONS - list of additional Python versions to search for # #============================================================================= @@ -19,25 +20,32 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -FIND_PROGRAM(PYTHON_EXECUTABLE - NAMES python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 python1.6 python1.5 python - PATHS - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.7\\InstallPath] - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.6\\InstallPath] - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.5\\InstallPath] - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.4\\InstallPath] - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.3\\InstallPath] - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.2\\InstallPath] - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.1\\InstallPath] - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.0\\InstallPath] - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\1.6\\InstallPath] - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\1.5\\InstallPath] - ) +# Set up the versions we know about, in the order we will search. Always add +# the user supplied additional versions to the front. +set(_Python_VERSIONS + ${Python_ADDITIONAL_VERSIONS} + 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0 1.6 1.5) + +# Run first with the Python version in the executable +foreach(_CURRENT_VERSION ${_Python_VERSIONS}) + set(_Python_NAMES python${_CURRENT_VERSION}) + if(WIN32) + list(APPEND _Python_NAMES python) + endif() + find_program(PYTHON_EXECUTABLE + NAMES ${_Python_NAMES} + PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath] + ) +endforeach() +# Now without any version if we still haven't found it +if(NOT PYTHON_EXECUTABLE) + find_program(PYTHON_EXECUTABLE NAMES python) +endif() + # handle the QUIETLY and REQUIRED arguments and set PYTHONINTERP_FOUND to TRUE if # all listed variables are TRUE -INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonInterp DEFAULT_MSG PYTHON_EXECUTABLE) -MARK_AS_ADVANCED(PYTHON_EXECUTABLE) - +mark_as_advanced(PYTHON_EXECUTABLE) |