Subject: [bug#77991] [PATCH 2/4] gnu: scotch: Keep *.cmake in the main output.

From: Ludovic Courtès <[email-masked]>
Date: Tue, 22 Apr 2025 17:31:48 +0200

From: Ludovic Courtès <[email-masked]>

This fixes a bug whereby ‘SCOTCHConfig.cmake’ would fail to find
‘scotchmetisTargets.cmake’ because it expects it to be in the same
directory as itself, ${CMAKE_CURRENT_LIST_DIR}.

* gnu/packages/maths.scm (scotch)[arguments]: Adjust ‘install-metis’
phase to keep *.cmake in “out”.

Change-Id: If8d8f890852c35cede6e81c33d18b9101988a635
---
 gnu/packages/maths.scm | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
index 2c53f6d8af..6a11103e3b 100644
--- a/gnu/packages/maths.scm
+++ b/gnu/packages/maths.scm
@@ -5220,15 +5220,22 @@ (define-public scotch
        (modify-phases %standard-phases
          (add-after 'install 'install-metis
            (lambda* (#:key outputs #:allow-other-keys)
+             ;; Move the METIS compatibility library to a separate output to
+             ;; avoid a name clash on <metis.h>.
              (let* ((out    (assoc-ref outputs "out"))
                     (metis  (assoc-ref outputs "metis"))
                     (prefix (string-length out)))
                (for-each (lambda (file)
-                           (let ((target (string-append
-                                          metis
-                                          (string-drop file prefix))))
-                             (mkdir-p (dirname target))
-                             (rename-file file target)))
+                           ;; 'SCOTCHConfig.cmake' includes
+                           ;; *metisTargets.cmake from
+                           ;; ${CMAKE_CURRENT_LIST_DIR} so keep all *.cmake
+                           ;; files in "out".
+                           (unless (string-suffix? ".cmake" file)
+                             (let ((target (string-append
+                                            metis
+                                            (string-drop file prefix))))
+                               (mkdir-p (dirname target))
+                               (rename-file file target))))
                          (find-files out "metis"))))))))
     (home-page "https://www.labri.fr/perso/pelegrin/scotch/")
     (properties
-- 
2.49.0