Subject: [PATCH sysadmin-team 2/2] gnu: spdlog: Unbundle fmt dependency.

From: Greg Hogan <[email-masked]>
Date: Wed, 23 Apr 2025 14:39:57 +0000

* gnu/packages/logging.scm (spdlog-1.15, spdlog-1.13, spdlog-1.10)
[source]: Remove bundled fmt ...
[propagated-inputs]: ... and add corresponding fmt.
[arguments]<#:configure-flags>: Use system fmt.
[license]: Remove fmt license.
(spdlog): Pin to spdlog-1.13.
* gnu/packages/xdisorg.scm (j4-dmenu-desktop)[inputs]: Replace spdlog
with spdlog-1.15 and remove fmt-11.

Change-Id: I8bea1e6a0cb375eaaeb8fdf0843a62d86d9fc4fd
---
 gnu/packages/logging.scm      | 28 +++++++++++++++++++++-------
 gnu/packages/pretty-print.scm |  2 +-
 gnu/packages/xdisorg.scm      |  2 +-
 3 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/gnu/packages/logging.scm b/gnu/packages/logging.scm
index a764fee5be..26525e5fc8 100644
--- a/gnu/packages/logging.scm
+++ b/gnu/packages/logging.scm
@@ -52,6 +52,7 @@ (define-module (gnu packages logging)
   #:use-module (gnu packages networking)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
+  #:use-module (gnu packages pretty-print)
   #:use-module (gnu packages python)
   #:use-module (gnu packages python-build)
   #:use-module (gnu packages python-check)
@@ -248,7 +249,9 @@ (define-public spdlog-1.15
              (commit (string-append "v" version))))
        (file-name (git-file-name name version))
        (sha256
-        (base32 "1drpbn7b6iikypdlsvzpcjwyls0rqzl7sz7f7xjbn3d7ic55a1p1"))))
+        (base32 "1drpbn7b6iikypdlsvzpcjwyls0rqzl7sz7f7xjbn3d7ic55a1p1"))
+       (modules '((guix build utils)))
+       (snippet #~(delete-file-recursively "include/spdlog/fmt/bundled"))))
     (build-system cmake-build-system)
     ;; TODO run benchmark. Currently not possible, as adding
     ;; (gnu packages benchmark) forms a dependency cycle
@@ -256,17 +259,17 @@ (define-public spdlog-1.15
      (list #:configure-flags
            #~(list "-DSPDLOG_BUILD_BENCH=OFF"
                    "-DSPDLOG_BUILD_SHARED=ON"
+                   "-DSPDLOG_FMT_EXTERNAL=ON"
                    #$@(if (%current-target-system)
                           '()
                           '("-DSPDLOG_BUILD_TESTS=ON")))))
     (native-inputs (list catch2-3))
+    (propagated-inputs (list fmt-11))
     (home-page "https://github.com/gabime/spdlog")
     (synopsis "Fast C++ logging library")
     (description "Spdlog is a very fast header-only/compiled C++ logging
 library.")
-    ;; spdlog is under Expat license, but the bundled fmt library in
-    ;; "include/spdlog/fmt/bundled" is under BSD 2 clause license.
-    (license (list license:expat license:bsd-2))))
+    (license license:expat)))
 
 (define-public spdlog-1.13
   (package/inherit spdlog-1.15
@@ -279,7 +282,12 @@ (define-public spdlog-1.13
              (commit (string-append "v" version))))
        (file-name (git-file-name (package-name spdlog-1.15) version))
        (sha256
-        (base32 "0zgdmdgnp2y36jrlk85d4fiyjkjd6anly8pambyc3f3v6sg02zyy"))))))
+        (base32 "0zgdmdgnp2y36jrlk85d4fiyjkjd6anly8pambyc3f3v6sg02zyy"))
+       (modules '((guix build utils)))
+       (snippet #~(delete-file-recursively "include/spdlog/fmt/bundled"))))
+    (propagated-inputs
+     (modify-inputs (package-propagated-inputs spdlog-1.15)
+       (replace "fmt" fmt-9)))))
 
 (define-public spdlog-1.10
   (package
@@ -293,9 +301,15 @@ (define-public spdlog-1.10
              (commit (string-append "v" version))))
        (file-name (git-file-name "spdlog" version))
        (sha256
-        (base32 "02xz017ba9fssm1rp1fcfld7h79awbr6fqai9dxaqp02akp3davk"))))))
+        (base32 "02xz017ba9fssm1rp1fcfld7h79awbr6fqai9dxaqp02akp3davk"))
+       (modules '((guix build utils)))
+       (snippet #~(delete-file-recursively "include/spdlog/fmt/bundled"))))
+    (propagated-inputs
+     (modify-inputs (package-propagated-inputs spdlog-1.15)
+       (replace "fmt" fmt-8)))))
 
-(define-public spdlog spdlog-1.15)
+;; Update when changing the pinned version of fmt.
+(define-public spdlog spdlog-1.13)
 
 (define-public rsyslog
   (package
diff --git a/gnu/packages/pretty-print.scm b/gnu/packages/pretty-print.scm
index fb676539b2..cd42582dc9 100644
--- a/gnu/packages/pretty-print.scm
+++ b/gnu/packages/pretty-print.scm
@@ -299,7 +299,7 @@ (define-public fmt-6
        ("clang" ,clang-6)))))
 
 ;; Note: Updating fmt causes some 1000s of rebuilds, so let's have a pinned
-;; version.
+;; version. When changing also update the pinned version of spdlog.
 (define-public fmt fmt-9)
 
 (define-public source-highlight
diff --git a/gnu/packages/xdisorg.scm b/gnu/packages/xdisorg.scm
index fee7e02d6e..18f1a19ff9 100644
--- a/gnu/packages/xdisorg.scm
+++ b/gnu/packages/xdisorg.scm
@@ -3538,7 +3538,7 @@ (define-public j4-dmenu-desktop
     (build-system meson-build-system)
     (native-inputs
      (list catch2-3 pkg-config))
-    (inputs (list spdlog fmt-11))
+    (inputs (list spdlog-1.15))
     (arguments
      (list
       #:configure-flags
-- 
2.49.0