diff --git a/CMakeLists.txt b/CMakeLists.txt index 96f5df6979..53357b894d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,10 +8,14 @@ project(rpm ) # user configurable stuff +include(CMakeDependentOption) option(ENABLE_CUTF8 "Enable C.UTF-8 as default locale" ON) option(ENABLE_NLS "Enable native language support" ON) option(ENABLE_OPENMP "Enable OpenMP threading support" ON) option(ENABLE_PYTHON "Enable Python bindings" ON) +cmake_dependent_option( + ENABLE_PYTHON_SABI "Build Python bindings with the Stable ABI" ON + "ENABLE_PYTHON; CMAKE_VERSION VERSION_GREATER_EQUAL 3.26" OFF) option(ENABLE_PLUGINS "Enable plugin support" ON) option(ENABLE_WERROR "Stop build on warnings" OFF) option(ENABLE_SQLITE "Enable sqlite rpmdb support" ON) @@ -234,7 +238,11 @@ endif() list(APPEND db_backends dummy) if (ENABLE_PYTHON) - find_package(Python3 3.2 COMPONENTS Interpreter Development REQUIRED) + if (ENABLE_PYTHON_SABI) + find_package(Python3 3.7 COMPONENTS Interpreter Development.SABIModule REQUIRED) + else () + find_package(Python3 3.2 COMPONENTS Interpreter Development REQUIRED) + endif () endif() if (WITH_CAP) @@ -344,6 +352,7 @@ if (LIBDW_FOUND) set(HAVE_LIBDW 1) endif() +include(CheckSymbolExists) check_symbol_exists(major "sys/sysmacros.h" MAJOR_IN_SYSMACROS) if (NOT MAJOR_IN_SYSMACROS) check_symbol_exists(major "sys/mkdev.h" MAJOR_IN_MKDEV) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 4149a88141..11acf3f362 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -1,4 +1,4 @@ -Python3_add_library(_rpm +set (sources rpmmodule.c rpmsystem-py.h header-py.c header-py.h rpmarchive-py.c rpmarchive-py.h @@ -17,6 +17,12 @@ Python3_add_library(_rpm rpmver-py.c rpmver-py.h spec-py.c spec-py.h ) + +if (ENABLE_PYTHON_SABI) + Python3_add_library(_rpm USE_SABI 3.7 ${sources}) +else () + Python3_add_library(_rpm ${sources}) +endif () target_link_libraries(_rpm PRIVATE librpmio librpm librpmbuild librpmsign)