summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-09-03 12:46:30 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-09-03 12:46:36 (GMT)
commit7658d5c52d653ec6da8301a412c69e6a4e7e651d (patch)
tree326ea193d19f8b71aad3aab430dba553b69c50d9
parent0782a6903798e49deaecd5636ec0a3e27a169b8e (diff)
parent6fdfe2428d70bbd7f264ca1010c7ce2e992e4ab3 (diff)
downloadCMake-7658d5c52d653ec6da8301a412c69e6a4e7e651d.zip
CMake-7658d5c52d653ec6da8301a412c69e6a4e7e651d.tar.gz
CMake-7658d5c52d653ec6da8301a412c69e6a4e7e651d.tar.bz2
Merge topic 'FindPython-include-dir-ABI-checks'
6fdfe2428d FindPython: enhance ABI checks against include directory Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !5181
-rw-r--r--Modules/FindPython/Support.cmake26
1 files changed, 18 insertions, 8 deletions
diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake
index 1d68c44..6dd3b8e 100644
--- a/Modules/FindPython/Support.cmake
+++ b/Modules/FindPython/Support.cmake
@@ -607,14 +607,24 @@ function (_PYTHON_GET_VERSION)
# ABI not used on Windows
set (abi "")
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")
+ if (NOT config)
+ # pyconfig.h can be a wrapper to a platform specific pyconfig.h
+ # In this case, try to identify ABI from include directory
+ if (_${_PYTHON_PREFIX}_INCLUDE_DIR MATCHES "python${version_major}\.${version_minor}+([dmu]*)")
+ set (abi "${CMAKE_MATCH_1}")
+ else()
+ set (abi "")
+ 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()
set (${_PGV_PREFIX}ABI "${abi}" PARENT_SCOPE)
endif()