[bug#77991,v2,2/4] gnu: scotch: Remove CMake machinery for the Metis compatibility layer.

Message ID 316ce8695c3b7b06fee2e483218b434ad8511b50.1745505295.git.ludo@gnu.org
State New
Headers
Series Upgrade Scotch to 7.0.7 |

Commit Message

Ludovic Courtès April 24, 2025, 2:36 p.m. UTC
  From: Ludovic Courtès <ludovic.courtes@inria.fr>

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/patches/scotch-cmake-remove-metis.patch: New file.
* gnu/packages/maths.scm (scotch)[source]: Use it.
* gnu/local.mk (dist_patch_DATA): Add it.

Change-Id: If8d8f890852c35cede6e81c33d18b9101988a635
---
 gnu/local.mk                                  |  1 +
 gnu/packages/maths.scm                        |  3 +++
 .../patches/scotch-cmake-remove-metis.patch   | 24 +++++++++++++++++++
 3 files changed, 28 insertions(+)
 create mode 100644 gnu/packages/patches/scotch-cmake-remove-metis.patch
  

Patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 4aa84f8ef9..a250b3f748 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -2249,6 +2249,7 @@  dist_patch_DATA =						\
   %D%/packages/patches/scilab-better-compiler-detection.patch	\
   %D%/packages/patches/scilab-tbx_build_help.patch		\
   %D%/packages/patches/scons-test-environment.patch		\
+  %D%/packages/patches/scotch-cmake-remove-metis.patch		\
   %D%/packages/patches/screen-hurd-path-max.patch		\
   %D%/packages/patches/scsh-nonstring-search-path.patch	\
   %D%/packages/patches/seed-webkit.patch			\
diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
index 7327aeaf40..33eb4cda7b 100644
--- a/gnu/packages/maths.scm
+++ b/gnu/packages/maths.scm
@@ -5200,6 +5200,7 @@  (define-public scotch
        (file-name (git-file-name name version))
        (sha256
         (base32 "0rbc51albpd2923dkirpkj8rfkic6rsvwqqnv1mmsk391zhk3amr"))
+       (patches (search-patches "scotch-cmake-remove-metis.patch"))
        (modules '((guix build utils)))
        (snippet
         #~(substitute* "src/libscotchmetis/library_parmetis.h"
@@ -5220,6 +5221,8 @@  (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)))
diff --git a/gnu/packages/patches/scotch-cmake-remove-metis.patch b/gnu/packages/patches/scotch-cmake-remove-metis.patch
new file mode 100644
index 0000000000..91bb36f86e
--- /dev/null
+++ b/gnu/packages/patches/scotch-cmake-remove-metis.patch
@@ -0,0 +1,24 @@ 
+Remove the CMake machinery for the Metis/Parmetis compatibility layer:
+it has zero users and complicates things due to the separate "metis"
+output.
+
+Notably, the assumption in 'SCOTCHConfig.cmake' is that *metisTargets.cmake
+are in the same directory, which is not the case here.  Furthermore,
+'*metisTargets-relwithdebuginfo.cmake' assumes 'libscotchmetis*.so*' is
+available under '_IMPORT_PREFIX', which is only the case when
+'libscotchmetis*.so' is installed in the same directory as 'libscotch.so'.
+
+diff --git a/cmake/SCOTCHConfig.cmake.in b/cmake/SCOTCHConfig.cmake.in
+index ec52ac5..4ce5c30 100644
+--- a/cmake/SCOTCHConfig.cmake.in
++++ b/cmake/SCOTCHConfig.cmake.in
+@@ -77,9 +77,3 @@ if(@BUILD_LIBESMUMPS@)
+     include("${CMAKE_CURRENT_LIST_DIR}/ptesmumpsTargets.cmake")
+   endif()
+ endif()
+-if(@BUILD_LIBSCOTCHMETIS@)
+-  include("${CMAKE_CURRENT_LIST_DIR}/scotchmetisTargets.cmake")
+-  if(@BUILD_PTSCOTCH@)
+-    include("${CMAKE_CURRENT_LIST_DIR}/ptscotchparmetisTargets.cmake")
+-  endif()
+-endif()