1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-16 14:08:35 +08:00

FindPython: enhance ABI checks against include directory

Fixes: #21149
This commit is contained in:
Marc Chevrier
2020-09-02 15:41:16 +02:00
parent 7da3c744e3
commit 6fdfe2428d

View File

@@ -607,14 +607,24 @@ function (_PYTHON_GET_VERSION)
# ABI not used on Windows # ABI not used on Windows
set (abi "") set (abi "")
else() else()
if (config MATCHES "#[ ]*define[ ]+Py_DEBUG[ ]+1") if (NOT config)
string (APPEND abi "d") # pyconfig.h can be a wrapper to a platform specific pyconfig.h
endif() # In this case, try to identify ABI from include directory
if (config MATCHES "#[ ]*define[ ]+WITH_PYMALLOC[ ]+1") if (_${_PYTHON_PREFIX}_INCLUDE_DIR MATCHES "python${version_major}\.${version_minor}+([dmu]*)")
string (APPEND abi "m") set (abi "${CMAKE_MATCH_1}")
endif() else()
if (config MATCHES "#[ ]*define[ ]+Py_UNICODE_SIZE[ ]+4") set (abi "")
string (APPEND abi "u") endif()
else()
if (config MATCHES "#[ ]*define[ ]+Py_DEBUG[ ]+1")
string (APPEND abi "d")
endif()
if (config MATCHES "#[ ]*define[ ]+WITH_PYMALLOC[ ]+1")
string (APPEND abi "m")
endif()
if (config MATCHES "#[ ]*define[ ]+Py_UNICODE_SIZE[ ]+4")
string (APPEND abi "u")
endif()
endif() endif()
set (${_PGV_PREFIX}ABI "${abi}" PARENT_SCOPE) set (${_PGV_PREFIX}ABI "${abi}" PARENT_SCOPE)
endif() endif()