Skip to content

Commit

Permalink
CMake: Add Python SABI option
Browse files Browse the repository at this point in the history
  • Loading branch information
jschueller committed Jan 30, 2025
1 parent 9148fba commit 5bbd51a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
16 changes: 11 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,24 @@ if (BUILD_PYTHON)
find_package (SWIG 3)
include (${SWIG_USE_FILE})

if (CMAKE_VERSION VERSION_LESS 3.26)
if (CMAKE_VERSION VERSION_LESS 3.18)
find_package (Python 3.6 COMPONENTS Interpreter Development)
if (NOT TARGET Python::Module)
include (TargetLinkLibrariesWithDynamicLookup)
endif ()
else ()
find_package (Python 3.6 COMPONENTS Interpreter Development.Module Development.SABIModule)
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)
include (FindPythonModule)
find_python_module (matplotlib)
if (NOT TARGET Python::Module)
include (TargetLinkLibrariesWithDynamicLookup)
endif ()

if (USE_SPHINX)
find_program (SPHINX_EXECUTABLE NAMES sphinx-build DOC "Sphinx Documentation Builder (sphinx-doc.org)")
Expand Down
1 change: 0 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"binaryDir": "${sourceDir}/build",
"generator": "Unix Makefiles",
"cacheVariables": {
"USE_SPHINX": "OFF",
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CMAKE_C_FLAGS": "-Wall -Wextra -Wpedantic -Wshadow",
"CMAKE_CXX_FLAGS": "-Wall -Wextra -Wpedantic -Wshadow -D_GLIBCXX_ASSERTIONS -fno-inline",
Expand Down

0 comments on commit 5bbd51a

Please sign in to comment.