diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a86815..1040f01 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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)") diff --git a/CMakePresets.json b/CMakePresets.json index ab07298..732d93d 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -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",