From bf66a46526908b1af3a17d354170081bc6dc25de Mon Sep 17 00:00:00 2001 From: Funda Wang Date: Fri, 22 Aug 2025 13:26:17 +0800 Subject: [PATCH] fix build with cmake 4 --- backport-gflags-cmake-4.patch | 49 +++++++++++++++++++++++++++ gflags-2.2.2-use-GNUInstallDirs.patch | 12 +++++++ gflags.spec | 9 +++-- 3 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 backport-gflags-cmake-4.patch create mode 100644 gflags-2.2.2-use-GNUInstallDirs.patch diff --git a/backport-gflags-cmake-4.patch b/backport-gflags-cmake-4.patch new file mode 100644 index 0000000..25bdeb5 --- /dev/null +++ b/backport-gflags-cmake-4.patch @@ -0,0 +1,49 @@ +From 70c01a642f08734b7bddc9687884844ca117e080 Mon Sep 17 00:00:00 2001 +From: Rui Chen +Date: Mon, 31 Mar 2025 18:35:49 -0400 +Subject: [PATCH] build: support cmake 4.0 (#367) + +Signed-off-by: Rui Chen +--- + CMakeLists.txt | 2 +- + test/config/CMakeLists.txt | 2 +- + test/nc/CMakeLists.txt | 2 +- + 3 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 4b5db235..a664bb12 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -70,7 +70,7 @@ + ## - GFLAGS_INSTALL_SHARED_LIBS + ## - GFLAGS_INSTALL_STATIC_LIBS + +-cmake_minimum_required (VERSION 3.0.2 FATAL_ERROR) ++cmake_minimum_required (VERSION 3.5 FATAL_ERROR) + + if (POLICY CMP0042) + cmake_policy (SET CMP0042 NEW) +diff --git a/test/config/CMakeLists.txt b/test/config/CMakeLists.txt +index 6190b253..205121e8 100644 +--- a/test/config/CMakeLists.txt ++++ b/test/config/CMakeLists.txt +@@ -1,6 +1,6 @@ + ## gflags package configuration tests + +-cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR) ++cmake_minimum_required (VERSION 3.5 FATAL_ERROR) + + project (gflags_${TEST_NAME}) + +diff --git a/test/nc/CMakeLists.txt b/test/nc/CMakeLists.txt +index d00b07d0..1b4d511a 100644 +--- a/test/nc/CMakeLists.txt ++++ b/test/nc/CMakeLists.txt +@@ -1,6 +1,6 @@ + ## gflags negative compilation tests + +-cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR) ++cmake_minimum_required (VERSION 3.5 FATAL_ERROR) + + if (NOT TEST_NAME) + message (FATAL_ERROR "Missing TEST_NAME CMake flag") diff --git a/gflags-2.2.2-use-GNUInstallDirs.patch b/gflags-2.2.2-use-GNUInstallDirs.patch new file mode 100644 index 0000000..59f48db --- /dev/null +++ b/gflags-2.2.2-use-GNUInstallDirs.patch @@ -0,0 +1,12 @@ +--- gflags-2.2.2/CMakeLists.txt.orig 2025-08-22 13:21:46.996390300 +0800 ++++ gflags-2.2.2/CMakeLists.txt 2025-08-22 13:23:51.189915800 +0800 +@@ -427,7 +427,8 @@ + if (NOT GFLAGS_LIBRARY_INSTALL_DIR AND LIB_INSTALL_DIR) + set (GFLAGS_LIBRARY_INSTALL_DIR "${LIB_INSTALL_DIR}") + endif () +- gflags_define (PATH LIBRARY_INSTALL_DIR "Directory of installed libraries, e.g., \"lib64\"" "lib${LIB_SUFFIX}") ++ include(GNUInstallDirs) ++ gflags_define (PATH LIBRARY_INSTALL_DIR "Directory of installed libraries, e.g., \"lib64\"" "${CMAKE_INSTALL_LIBDIR}") + gflags_property (LIBRARY_INSTALL_DIR ADVANCED TRUE) + set (INCLUDE_INSTALL_DIR include) + set (CONFIG_INSTALL_DIR ${LIBRARY_INSTALL_DIR}/cmake/${PACKAGE_NAME}) diff --git a/gflags.spec b/gflags.spec index 7310ea9..8bd97af 100644 --- a/gflags.spec +++ b/gflags.spec @@ -1,13 +1,15 @@ Name: gflags Version: 2.2.2 -Release: 4 +Release: 5 Summary: A C++ library for commandline flag processing License: BSD-3-Clause URL: https://gflags.github.io/gflags/ Source0: https://github.com/gflags/gflags/archive/v%{version}/gflags-%{version}.tar.gz Patch0: gflags-fix_pkgconfig.patch +Patch1: backport-gflags-cmake-4.patch +Patch2: gflags-2.2.2-use-GNUInstallDirs.patch BuildRequires: gcc-c++ -BuildRequires: cmake >= 3.0.2 +BuildRequires: cmake >= 3.5 %description The gflags package contains a library that implements commandline @@ -54,6 +56,9 @@ This package contains development files for gflags. %{_libdir}/cmake/gflags %changelog +* Fri Aug 22 2025 Funda Wang - 2.2.2-5 +- fix build with cmake 4 + * Wed Oct 16 2024 Funda Wang - 2.2.2-4 - Fix pkgconfig libdir value -- Gitee