From afb0ffcac7852e1c2d7472ee914081e5eaf0cfe0 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 4 Dec 2020 13:58:34 -0500 Subject: FindPython2: avoid doubling the extension in CPython2 SOABI Commit 951640f1f9 (FindPython: manage SOABI for all Python versions, 2020-08-11) extended support for Python2's SOABI variable in order to support the PyPy interpreter as well. This caused a regression in the way that the SOABI variable was built up for the CPython interpreter. This caused the variable to be set to `.so` which ended up causing a doubling of the resulting `SOABI` variable in the end. Co-Author: Marc Chevrier Fixes: #21548 --- Modules/FindPython/Support.cmake | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'Modules/FindPython') diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index c8225c4c58..3732463d06 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -452,7 +452,11 @@ function (_PYTHON_GET_CONFIG_VAR _PYTHON_PGCV_VALUE NAME) list (REMOVE_DUPLICATES _values) elseif (NAME STREQUAL "SOABI") # clean-up: remove prefix character and suffix - string (REGEX REPLACE "^[.-](.+)(${CMAKE_SHARED_LIBRARY_SUFFIX}|\\.(so|pyd))$" "\\1" _values "${_values}") + if (_values MATCHES "^(\\.${CMAKE_SHARED_LIBRARY_SUFFIX}|\\.so|\\.pyd)$") + set(_values "") + else() + string (REGEX REPLACE "^[.-](.+)(${CMAKE_SHARED_LIBRARY_SUFFIX}|\\.(so|pyd))$" "\\1" _values "${_values}") + endif() endif() endif() endif() @@ -504,7 +508,11 @@ function (_PYTHON_GET_CONFIG_VAR _PYTHON_PGCV_VALUE NAME) endforeach() if (_values) # clean-up: remove prefix character and suffix - string (REGEX REPLACE "^[.-](.+)(${CMAKE_SHARED_LIBRARY_SUFFIX}|\\.(so|pyd))$" "\\1" _values "${_values}") + if (_values MATCHES "^(\\.${CMAKE_SHARED_LIBRARY_SUFFIX}|\\.so|\\.pyd)$") + set(_values "") + else() + string (REGEX REPLACE "^[.-](.+)(${CMAKE_SHARED_LIBRARY_SUFFIX}|\\.(so|pyd))$" "\\1" _values "${_values}") + endif() endif() endif() else() -- cgit v1.2.1