From 8df58dff9d5627770e5c6b064e86b487a1becc0d Mon Sep 17 00:00:00 2001 From: Funda Wang Date: Fri, 14 Mar 2025 17:20:22 +0800 Subject: [PATCH] fix build with cmake 4.0 --- ...rease-CMake-minimal-version-to-3.5.0.patch | 88 +++++++++++++++++++ libdnf.spec | 6 +- 2 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 backport-build-Increase-CMake-minimal-version-to-3.5.0.patch diff --git a/backport-build-Increase-CMake-minimal-version-to-3.5.0.patch b/backport-build-Increase-CMake-minimal-version-to-3.5.0.patch new file mode 100644 index 0000000..e93bd8d --- /dev/null +++ b/backport-build-Increase-CMake-minimal-version-to-3.5.0.patch @@ -0,0 +1,88 @@ +From 099600ca94f3b205461cc010dd257d9d1abd068d Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= +Date: Fri, 28 Feb 2025 15:33:33 +0100 +Subject: [PATCH] build: Increase CMake minimal version to 3.5.0 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +CMake 4.0.0 removed a support for CMake < 3.5, causing a configure +error: + + CMake Error at CMakeLists.txt:7 (cmake_minimum_required): + Compatibility with CMake < 3.5 has been removed from CMake. + + Update the VERSION argument value. Or, use the ... syntax + to tell CMake that the project requires at least but has been updated + to work with policies introduced by or earlier. + + Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway. + +This patch moves CMakeList.txt to the earliest supported version, +3.5.0. It also ports the script to CMP0005 policy which cannot be +disabled anymore. It also moves GNUInstallDirs inclusion after +project() as it requires it for probing a library path. + +New CMake deprecation warnigs will be resolved later. + +Resolves #1699 + +Signed-off-by: Petr Písař +--- + CMakeLists.txt | 23 +++++++++++------------ + 1 file changed, 11 insertions(+), 12 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index c6bd46a6..76670959 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,17 +1,16 @@ +-# print initial information about the project +-message("Running CMake on libdnf...") +-project(libdnf C CXX) +- +- + # cmake requirements and policies +-cmake_minimum_required(VERSION 2.8.5) +-cmake_policy(SET CMP0005 OLD) ++cmake_minimum_required(VERSION 3.5.0) + # Avoid a warning because "hth" links to + # the in-tree libhawkey, but uses pkg-config to find + # GLib. There may be a better way to do this... + cmake_policy(SET CMP0003 NEW) +-include(GNUInstallDirs) + ++# print initial information about the project ++message("Running CMake on libdnf...") ++project(libdnf C CXX) ++ ++# GNUInstallDirs requires a language set with project() ++include(GNUInstallDirs) + + # use project specific cmake modules + set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules) +@@ -122,20 +121,20 @@ + set(CMAKE_MACOSX_RPATH 0) + + # package/project version +-add_definitions(-DPACKAGE_VERSION=\\"${LIBDNF_VERSION}\\") ++add_definitions(-DPACKAGE_VERSION="${LIBDNF_VERSION}") + + # The libdnf API is under development now. This enables it for internal usage. + add_definitions(-DLIBDNF_UNSTABLE_API) + + # gettext +-add_definitions(-DGETTEXT_DOMAIN=\\"libdnf\\") +-add_definitions(-DG_LOG_DOMAIN=\\"libdnf\\") ++add_definitions(-DGETTEXT_DOMAIN="libdnf") ++add_definitions(-DG_LOG_DOMAIN="libdnf") + + # gpgme: LargeFile Support is required on 32bit architectures + add_definitions(-D_FILE_OFFSET_BITS=64) + + # tests +-add_definitions(-DTESTDATADIR=\\"${CMAKE_SOURCE_DIR}/data/tests\\") ++add_definitions(-DTESTDATADIR="${CMAKE_SOURCE_DIR}/data/tests") + + # librhsm + if(ENABLE_RHSM_SUPPORT) diff --git a/libdnf.spec b/libdnf.spec index ca00832..322d6cd 100644 --- a/libdnf.spec +++ b/libdnf.spec @@ -18,7 +18,7 @@ Name: libdnf Version: 0.70.2 -Release: 7 +Release: 8 Summary: Library providing simplified C and Python API to libsolv License: LGPL-2.1-or-later URL: https://github.com/rpm-software-management/libdnf @@ -54,6 +54,7 @@ Patch6008: backport-MergedTransaction-Fix-invalid-memory-access- Patch6009: backport-Fix-countme-bucket-calculation.patch Patch6010: backport-Fix-up-some-comments-in-addCountmeFlag.patch Patch6011: backport-Fix-a-memory-leak-in-glob_for_cachedir.patch +Patch6012: backport-build-Increase-CMake-minimal-version-to-3.5.0.patch %description A Library providing simplified C and Python API to libsolv. @@ -124,6 +125,9 @@ Python 3 bindings for the hawkey library. %{python3_sitearch}/hawkey/ %changelog +* Fri Mar 14 2025 Funda Wang - 0.70.2-8 +- fix build with cmake 4.0 + * Mon Nov 11 2024 Funda Wang - 0.70.2-7 - adopt to new cmake macro -- Gitee