FindPython: manage SOABI for all Python versions

Fixes: #21070
This commit is contained in:
Marc Chevrier
2020-08-11 10:16:40 +02:00
parent b8214a87bf
commit 951640f1f9
2 changed files with 20 additions and 12 deletions
+16
View File
@@ -20,3 +20,19 @@ if (Python3_Development_FOUND AND Python3_SOABI)
message(FATAL_ERROR "Module suffix do not include Python3_SOABI")
endif()
endif()
find_package(Python2 COMPONENTS ${CMake_TEST_FindPython_COMPONENT})
if(NOT DEFINED Python2_SOABI)
message(FATAL_ERROR "Python2_SOABI for ${CMake_TEST_FindPython_COMPONENT} not found")
endif()
if (Python2_Development_FOUND AND Python2_SOABI)
Python2_add_library (spam2 MODULE WITH_SOABI ../spam.c)
target_compile_definitions (spam2 PRIVATE PYTHON2)
get_property (suffix TARGET spam2 PROPERTY SUFFIX)
if (NOT suffix MATCHES "^.${Python2_SOABI}")
message(FATAL_ERROR "Module suffix do not include Python2_SOABI")
endif()
endif()