FindPythonLibs: Match include dir to library version
This commit ensures that FindPythonLibs has found the library before before the search for the include dir begins. The library prefix and version can then be used to find the matching include dir.
This commit is contained in:
parent
ea2db3bb02
commit
a9d32dffb9
|
@ -150,6 +150,18 @@ foreach(_CURRENT_VERSION ${_Python_VERSIONS})
|
||||||
PATH_SUFFIXES python${_CURRENT_VERSION}/config
|
PATH_SUFFIXES python${_CURRENT_VERSION}/config
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Don't search for include dir until library location is known
|
||||||
|
if(PYTHON_LIBRARY)
|
||||||
|
|
||||||
|
# Use the library's install prefix as a hint
|
||||||
|
set(_Python_INCLUDE_PATH_HINT)
|
||||||
|
get_filename_component(_PREFIX ${PYTHON_LIBRARY} PATH)
|
||||||
|
get_filename_component(_PREFIX ${_PREFIX} PATH)
|
||||||
|
if(_PREFIX)
|
||||||
|
set(_Python_INCLUDE_PATH_HINT ${_PREFIX}/include)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Add framework directories to the search paths
|
||||||
set(PYTHON_FRAMEWORK_INCLUDES)
|
set(PYTHON_FRAMEWORK_INCLUDES)
|
||||||
if(Python_FRAMEWORKS AND NOT PYTHON_INCLUDE_DIR)
|
if(Python_FRAMEWORKS AND NOT PYTHON_INCLUDE_DIR)
|
||||||
foreach(dir ${Python_FRAMEWORKS})
|
foreach(dir ${Python_FRAMEWORKS})
|
||||||
|
@ -160,6 +172,8 @@ foreach(_CURRENT_VERSION ${_Python_VERSIONS})
|
||||||
|
|
||||||
find_path(PYTHON_INCLUDE_DIR
|
find_path(PYTHON_INCLUDE_DIR
|
||||||
NAMES Python.h
|
NAMES Python.h
|
||||||
|
HINTS
|
||||||
|
${_Python_INCLUDE_PATH_HINT}
|
||||||
PATHS
|
PATHS
|
||||||
${PYTHON_FRAMEWORK_INCLUDES}
|
${PYTHON_FRAMEWORK_INCLUDES}
|
||||||
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/include
|
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/include
|
||||||
|
@ -170,6 +184,7 @@ foreach(_CURRENT_VERSION ${_Python_VERSIONS})
|
||||||
python${_CURRENT_VERSION}u
|
python${_CURRENT_VERSION}u
|
||||||
python${_CURRENT_VERSION}
|
python${_CURRENT_VERSION}
|
||||||
)
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
# For backward compatibility, set PYTHON_INCLUDE_PATH.
|
# For backward compatibility, set PYTHON_INCLUDE_PATH.
|
||||||
set(PYTHON_INCLUDE_PATH "${PYTHON_INCLUDE_DIR}")
|
set(PYTHON_INCLUDE_PATH "${PYTHON_INCLUDE_DIR}")
|
||||||
|
@ -187,6 +202,8 @@ foreach(_CURRENT_VERSION ${_Python_VERSIONS})
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
unset(_Python_INCLUDE_PATH_HINT)
|
||||||
|
|
||||||
mark_as_advanced(
|
mark_as_advanced(
|
||||||
PYTHON_DEBUG_LIBRARY
|
PYTHON_DEBUG_LIBRARY
|
||||||
PYTHON_LIBRARY
|
PYTHON_LIBRARY
|
||||||
|
|
Loading…
Reference in New Issue