Improve FindPythonLibsNew detection of python library directory (#523)

* Use LIBDIR and MULTIARCH on linux to find python library

* Remove apple-specific setting; the non-windows one should work fine on OS X

* Default LIBDIR/MULTIARCH to '' (to avoid getting None)

* Remove trailing whitespace from FindPythonLibsNew
This commit is contained in:
Jason Rhinelander 2016-11-22 15:59:18 -05:00 committed by Wenzel Jakob
parent 5271576828
commit 2ac2d69418

View File

@ -82,11 +82,12 @@ print(s.get_config_var('SO'));
print(hasattr(sys, 'gettotalrefcount')+0); print(hasattr(sys, 'gettotalrefcount')+0);
print(struct.calcsize('@P')); print(struct.calcsize('@P'));
print(s.get_config_var('LDVERSION') or s.get_config_var('VERSION')); print(s.get_config_var('LDVERSION') or s.get_config_var('VERSION'));
print(s.get_config_var('LIBDIR') or '');
print(s.get_config_var('MULTIARCH') or '');
" "
RESULT_VARIABLE _PYTHON_SUCCESS RESULT_VARIABLE _PYTHON_SUCCESS
OUTPUT_VARIABLE _PYTHON_VALUES OUTPUT_VARIABLE _PYTHON_VALUES
ERROR_VARIABLE _PYTHON_ERROR_VALUE ERROR_VARIABLE _PYTHON_ERROR_VALUE)
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT _PYTHON_SUCCESS MATCHES 0) if(NOT _PYTHON_SUCCESS MATCHES 0)
if(PythonLibsNew_FIND_REQUIRED) if(PythonLibsNew_FIND_REQUIRED)
@ -108,6 +109,8 @@ list(GET _PYTHON_VALUES 4 PYTHON_MODULE_EXTENSION)
list(GET _PYTHON_VALUES 5 PYTHON_IS_DEBUG) list(GET _PYTHON_VALUES 5 PYTHON_IS_DEBUG)
list(GET _PYTHON_VALUES 6 PYTHON_SIZEOF_VOID_P) list(GET _PYTHON_VALUES 6 PYTHON_SIZEOF_VOID_P)
list(GET _PYTHON_VALUES 7 PYTHON_LIBRARY_SUFFIX) list(GET _PYTHON_VALUES 7 PYTHON_LIBRARY_SUFFIX)
list(GET _PYTHON_VALUES 8 PYTHON_LIBDIR)
list(GET _PYTHON_VALUES 9 PYTHON_MULTIARCH)
# Make sure the Python has the same pointer-size as the chosen compiler # Make sure the Python has the same pointer-size as the chosen compiler
# Skip if CMAKE_SIZEOF_VOID_P is not defined # Skip if CMAKE_SIZEOF_VOID_P is not defined
@ -151,14 +154,11 @@ if(CMAKE_HOST_WIN32)
message(FATAL_ERROR "Python libraries not found") message(FATAL_ERROR "Python libraries not found")
endif() endif()
elseif(APPLE)
set(PYTHON_LIBRARY
"${PYTHON_PREFIX}/lib/libpython${PYTHON_LIBRARY_SUFFIX}.dylib")
else() else()
if(${PYTHON_SIZEOF_VOID_P} MATCHES 8) if(PYTHON_MULTIARCH)
set(_PYTHON_LIBS_SEARCH "${PYTHON_PREFIX}/lib64" "${PYTHON_PREFIX}/lib") set(_PYTHON_LIBS_SEARCH "${PYTHON_LIBDIR}/${PYTHON_MULTIARCH}" "${PYTHON_LIBDIR}")
else() else()
set(_PYTHON_LIBS_SEARCH "${PYTHON_PREFIX}/lib") set(_PYTHON_LIBS_SEARCH "${PYTHON_LIBDIR}")
endif() endif()
#message(STATUS "Searching for Python libs in ${_PYTHON_LIBS_SEARCH}") #message(STATUS "Searching for Python libs in ${_PYTHON_LIBS_SEARCH}")
# Probably this needs to be more involved. It would be nice if the config # Probably this needs to be more involved. It would be nice if the config