FindPythonLibs: Find consistent Python interp, headers, libs (#13794)

When possible, get consistent version of the Python interpreter, headers path,
and library.

Now find_package(PythonLibs) internally calls find_package(PythonInterp
QUIET) and uses the resulting PYTHON_VERSION_MAJOR and
PYTHON_VERSION_MINOR to prefer these versions when looking for the
header path and library.  The Python_ADDITIONAL_VERSIONS variable has
priority over the interpreter version.

Co-Author: Adam Wolf
Co-Author: Gert Wollny <gw.fossdev@gmail.com>
This commit is contained in:
Matt McCormick 2014-02-26 21:47:20 -05:00 committed by Brad King
parent 6e6fbb0e43
commit 3816cd2dc7
1 changed files with 9 additions and 4 deletions

View File

@ -80,10 +80,15 @@ endif()
# Set up the versions we know about, in the order we will search. Always add # Set up the versions we know about, in the order we will search. Always add
# the user supplied additional versions to the front. # the user supplied additional versions to the front.
set(_Python_VERSIONS # If FindPythonInterp has already found the major and minor version,
${Python_ADDITIONAL_VERSIONS} # insert that version between the user supplied versions and the stock
${_PYTHON_FIND_OTHER_VERSIONS} # version list.
) find_package(PythonInterp QUIET)
set(_Python_VERSIONS ${Python_ADDITIONAL_VERSIONS})
if(DEFINED PYTHON_VERSION_MAJOR AND DEFINED PYTHON_VERSION_MINOR)
list(APPEND _Python_VERSIONS ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
endif()
list(APPEND _Python_VERSIONS ${_PYTHON_FIND_OTHER_VERSIONS})
unset(_PYTHON_FIND_OTHER_VERSIONS) unset(_PYTHON_FIND_OTHER_VERSIONS)
unset(_PYTHON1_VERSIONS) unset(_PYTHON1_VERSIONS)