Skip to content

Commit

Permalink
CMake: Add option to select Python SABI
Browse files Browse the repository at this point in the history
  • Loading branch information
jschueller committed Jan 14, 2025
1 parent 0a3d468 commit cc69009
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -549,14 +549,17 @@ if (BUILD_PYTHON)
endif ()
endif ()

if (CMAKE_VERSION VERSION_LESS 3.26)
if (CMAKE_VERSION VERSION_LESS 3.18)
find_package (Python 3.6 COMPONENTS Interpreter Development)
else ()
find_package (Python 3.6 COMPONENTS Interpreter Development.Module Development.SABIModule)
endif ()

if (NOT TARGET Python::Module)
include (TargetLinkLibrariesWithDynamicLookup)
else ()
option (USE_PYTHON_SABI "Use Python stable ABI" OFF)
if (USE_PYTHON_SABI AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.26)
find_package (Python 3.6 COMPONENTS Interpreter Development.SABIModule)
add_library (Python::Module ALIAS Python::SABIModule)
else ()
find_package (Python 3.6 COMPONENTS Interpreter Development.Module)
endif ()
endif ()

if (Python_FOUND)
Expand Down

0 comments on commit cc69009

Please sign in to comment.