Subject: [bug#64137] [PATCH v2 6/8] gnu: clingo: Unbundle dependencies.

From: David Elsing <[email-masked]>
Date: Sun, 18 Jun 2023 20:53:05 +0000

* gnu/packages/potassco.scm: (clingo)
[arguments]<#:phases>: Patch CMakeLists.txt files to use external dependencies.
[native-inputs]: Add mpark-variant, tl-optional, tsl-hopscotch-map,
tsl-ordered-map and tsl-sparse-map.
---
 gnu/packages/potassco.scm | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/potassco.scm b/gnu/packages/potassco.scm
index 03d243cdc7..b8e51e7d47 100644
--- a/gnu/packages/potassco.scm
+++ b/gnu/packages/potassco.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2022, 2023 Liliana Marie Prikler <[email-masked]>
 ;;; Copyright © 2023 Simon Tournier <[email-masked]>
+;;; Copyright © 2023 David Elsing <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -31,6 +32,7 @@ (define-module (gnu packages potassco)
   #:use-module (guix build-system python)
   #:use-module (guix build-system pyproject)
   #:use-module (gnu packages check)
+  #:use-module (gnu packages cpp)
   #:use-module (gnu packages graphviz)
   #:use-module (gnu packages libffi)
   #:use-module (gnu packages pkg-config)
@@ -153,8 +155,7 @@ (define-public clingo
               (snippet
                #~(begin
                    (delete-file-recursively "clasp")
-                   ;; TODO: Unvendor other third-party stuff
-                   (delete-file-recursively "third_party/catch")))
+                   (delete-file-recursively "third_party")))
               (sha256
                (base32
                 "19s59ndcm2yj0kxlikfxnx2bmp6b7n31wq1zvwc7hyk37rqarwys"))))
@@ -173,12 +174,22 @@ (define-public clingo
             (lambda _
               (substitute* "CMakeLists.txt"
                 (("add_subdirectory\\(clasp\\)")
-                 "find_package(clasp REQUIRED)"))
+                 "find_package(clasp REQUIRED)")
+                (("add_subdirectory\\(third_party\\)")
+                 (string-append
+                  "find_package(tsl-hopscotch-map)\n"
+                  "find_package(tl-optional)\n"
+                  "find_package(mpark_variant)\n"
+                  "find_package(tsl-sparse-map)\n"
+                  "find_package(tsl-ordered-map)\n"
+                  "find_package(Catch2 3 REQUIRED)")))
               (substitute* "libclingo/CMakeLists.txt"
                 (("\"cmake/Clingo\"") "\"cmake/clingo\"")
                 (("ClingoConfig\\.cmake") "clingo-config.cmake")
                 (("ClingoConfigVersion\\.cmake")
                  "clingo-config-version.cmake"))
+              (substitute* "libgringo/CMakeLists.txt"
+                (("mpark::variant") "mpark_variant"))
               (substitute* "cmake/ClingoConfig.cmake.in"
                 (("find_package\\(Clasp") "find_package(clasp"))
               (rename-file "cmake/ClingoConfig.cmake.in"
@@ -199,7 +210,12 @@ (define-public clingo
                                 "propagator" "propgator-sequence-mining"
                                 "symbol" "visitor"))))))))))
     (inputs (list catch2-3.1 clasp libpotassco))
-    (native-inputs (list pkg-config))
+    (native-inputs (list mpark-variant
+                         pkg-config
+                         tl-optional
+                         tsl-hopscotch-map
+                         tsl-ordered-map
+                         tsl-sparse-map))
     (home-page "https://potassco.org/")
     (synopsis "Grounder and solver for logic programs")
     (description "Clingo computes answer sets for a given logic program.")
-- 
2.40.1