summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-12-03 14:04:15 (GMT)
committerKitware Robot <kwrobot@kitware.com>2024-12-03 14:04:41 (GMT)
commit50afcb61f7ef81cde2fc6e46f9bd04346f188803 (patch)
treef6af568e7b17ee9c210991ff73e5ab6bf60c1e6e
parentdb3930323bb9f87e06d36f57842a2015965078c0 (diff)
parentff65c5fca05ad11c564b2e193205f44b65376b6d (diff)
downloadCMake-50afcb61f7ef81cde2fc6e46f9bd04346f188803.zip
CMake-50afcb61f7ef81cde2fc6e46f9bd04346f188803.tar.gz
CMake-50afcb61f7ef81cde2fc6e46f9bd04346f188803.tar.bz2
Merge topic 'FindPython-SABIModule-handling' into release-3.31
ff65c5fca0 FindPython: Ensure SABIModule is found in all cases Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Merge-request: !10058
-rw-r--r--Modules/FindPython/Support.cmake7
-rw-r--r--Tests/FindPython/RequiredArtifacts/CMakeLists.txt49
2 files changed, 53 insertions, 3 deletions
diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake
index e0bdbc5..c741ec1 100644
--- a/Modules/FindPython/Support.cmake
+++ b/Modules/FindPython/Support.cmake
@@ -3464,14 +3464,15 @@ if (("Development.Module" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
endif()
# finalize library version information
- _python_get_version (SABI_LIBRARY PREFIX _${_PYTHON_PREFIX}_)
# ABI library does not have the full version information
- if (${_PYTHON_PREFIX}_Interpreter_FOUND OR _${_PYTHON_PREFIX}_LIBRARY_RELEASE)
- # update from interpreter or library
+ if (${_PYTHON_PREFIX}_Interpreter_FOUND AND NOT _${_PYTHON_PREFIX}_LIBRARY_RELEASE)
+ # update from interpreter
set (_${_PYTHON_PREFIX}_VERSION ${${_PYTHON_PREFIX}_VERSION})
set (_${_PYTHON_PREFIX}_VERSION_MAJOR ${${_PYTHON_PREFIX}_VERSION_MAJOR})
set (_${_PYTHON_PREFIX}_VERSION_MINOR ${${_PYTHON_PREFIX}_VERSION_MINOR})
set (_${_PYTHON_PREFIX}_VERSION_PATCH ${${_PYTHON_PREFIX}_VERSION_PATCH})
+ elseif(NOT _${_PYTHON_PREFIX}_LIBRARY_RELEASE)
+ _python_get_version (SABI_LIBRARY PREFIX _${_PYTHON_PREFIX}_)
endif()
set (${_PYTHON_PREFIX}_SABI_LIBRARY_RELEASE "${_${_PYTHON_PREFIX}_SABI_LIBRARY_RELEASE}")
diff --git a/Tests/FindPython/RequiredArtifacts/CMakeLists.txt b/Tests/FindPython/RequiredArtifacts/CMakeLists.txt
index 5df01c6..8be39bf 100644
--- a/Tests/FindPython/RequiredArtifacts/CMakeLists.txt
+++ b/Tests/FindPython/RequiredArtifacts/CMakeLists.txt
@@ -16,6 +16,55 @@ else()
set(USER_INCLUDE_DIR "/path/to/invalid/dir")
endif()
+# check some combinations for modules search without interpreter
+block(SCOPE_FOR VARIABLES)
+ find_package(Python3 REQUIRED COMPONENTS Development.SABIModule)
+ if (NOT Python3_FOUND)
+ message (FATAL_ERROR "Failed to find Python 3")
+ endif()
+ if (Python3_Development_FOUND)
+ message (FATAL_ERROR "Python 3, COMPONENT 'Development' unexpectedly found")
+ endif()
+ if (Python3_Interpreter_FOUND)
+ message (FATAL_ERROR "Python 3, COMPONENT 'Interpreter' unexpectedly found")
+ endif()
+ if (Python3_Development.Embed_FOUND)
+ message (FATAL_ERROR "Python 3, COMPONENT 'Development.Embed' unexpectedly found")
+ endif()
+ if (Python3_Development.Module_FOUND)
+ message (FATAL_ERROR "Python 3, COMPONENT 'Development.Module' unexpectedly found")
+ endif()
+ if (NOT Python3_Development.SABIModule_FOUND)
+ message (FATAL_ERROR "Python 3, COMPONENT 'Development.SABIModule' not found")
+ endif()
+ unset(_Python3_SABI_LIBRARY_RELEASE CACHE)
+endblock()
+
+block(SCOPE_FOR VARIABLES)
+ find_package(Python3 REQUIRED COMPONENTS Development.Module Development.SABIModule)
+ if (NOT Python3_FOUND)
+ message (FATAL_ERROR "Failed to find Python 3")
+ endif()
+ if (Python3_Development_FOUND)
+ message (FATAL_ERROR "Python 3, COMPONENT 'Development' unexpectedly found")
+ endif()
+ if (Python3_Interpreter_FOUND)
+ message (FATAL_ERROR "Python 3, COMPONENT 'Interpreter' unexpectedly found")
+ endif()
+ if (Python3_Development.Embed_FOUND)
+ message (FATAL_ERROR "Python 3, COMPONENT 'Development.Embed' unexpectedly found")
+ endif()
+ if (NOT Python3_Development.Module_FOUND)
+ message (FATAL_ERROR "Python 3, COMPONENT 'Development.Module' not found")
+ endif()
+ if (NOT Python3_Development.SABIModule_FOUND)
+ message (FATAL_ERROR "Python 3, COMPONENT 'Development.SABIModule' not found")
+ endif()
+ unset(_Python3_LIBRARY_RELEASE CACHE)
+ unset(_Python3_SABI_LIBRARY_RELEASE CACHE)
+endblock()
+
+
set(components Interpreter Development)
if (CMake_TEST_FindPython3_SABIModule AND WIN32)
list (APPEND components Development.SABIModule)