mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-25 14:45:12 +00:00
CMake improvement: support windows python on msys (#2312)
- look for windows python lib when using mingw & msys - if not found, then look for system python lib as before
This commit is contained in:
parent
d8c7ee00a6
commit
c4fd1fd987
@ -147,7 +147,7 @@ string(REGEX REPLACE "\\\\" "/" PYTHON_PREFIX "${PYTHON_PREFIX}")
|
|||||||
string(REGEX REPLACE "\\\\" "/" PYTHON_INCLUDE_DIR "${PYTHON_INCLUDE_DIR}")
|
string(REGEX REPLACE "\\\\" "/" PYTHON_INCLUDE_DIR "${PYTHON_INCLUDE_DIR}")
|
||||||
string(REGEX REPLACE "\\\\" "/" PYTHON_SITE_PACKAGES "${PYTHON_SITE_PACKAGES}")
|
string(REGEX REPLACE "\\\\" "/" PYTHON_SITE_PACKAGES "${PYTHON_SITE_PACKAGES}")
|
||||||
|
|
||||||
if(CMAKE_HOST_WIN32 AND NOT (MINGW AND DEFINED ENV{MSYSTEM}))
|
if(CMAKE_HOST_WIN32)
|
||||||
set(PYTHON_LIBRARY
|
set(PYTHON_LIBRARY
|
||||||
"${PYTHON_PREFIX}/libs/python${PYTHON_LIBRARY_SUFFIX}.lib")
|
"${PYTHON_PREFIX}/libs/python${PYTHON_LIBRARY_SUFFIX}.lib")
|
||||||
|
|
||||||
@ -159,6 +159,20 @@ if(CMAKE_HOST_WIN32 AND NOT (MINGW AND DEFINED ENV{MSYSTEM}))
|
|||||||
"${_PYTHON_ROOT}/libs/python${PYTHON_LIBRARY_SUFFIX}.lib")
|
"${_PYTHON_ROOT}/libs/python${PYTHON_LIBRARY_SUFFIX}.lib")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# if we are in MSYS & MINGW, and we didn't find windows python lib, look for system python lib
|
||||||
|
if(DEFINED ENV{MSYSTEM} AND MINGW AND NOT EXISTS "${PYTHON_LIBRARY}")
|
||||||
|
if(PYTHON_MULTIARCH)
|
||||||
|
set(_PYTHON_LIBS_SEARCH "${PYTHON_LIBDIR}/${PYTHON_MULTIARCH}" "${PYTHON_LIBDIR}")
|
||||||
|
else()
|
||||||
|
set(_PYTHON_LIBS_SEARCH "${PYTHON_LIBDIR}")
|
||||||
|
endif()
|
||||||
|
unset(PYTHON_LIBRARY)
|
||||||
|
find_library(PYTHON_LIBRARY
|
||||||
|
NAMES "python${PYTHON_LIBRARY_SUFFIX}"
|
||||||
|
PATHS ${_PYTHON_LIBS_SEARCH}
|
||||||
|
NO_DEFAULT_PATH)
|
||||||
|
endif()
|
||||||
|
|
||||||
# raise an error if the python libs are still not found.
|
# raise an error if the python libs are still not found.
|
||||||
if(NOT EXISTS "${PYTHON_LIBRARY}")
|
if(NOT EXISTS "${PYTHON_LIBRARY}")
|
||||||
message(FATAL_ERROR "Python libraries not found")
|
message(FATAL_ERROR "Python libraries not found")
|
||||||
|
Loading…
Reference in New Issue
Block a user