File 0001-Find-MUMPS-before-linking.patch of Package sparselizard
From 3e8d004b27bd65957582b1f127c183ebc8c399fb Mon Sep 17 00:00:00 2001
From: "Matwey V. Kornilov" <matwey.kornilov@gmail.com>
Date: Mon, 20 Nov 2023 13:54:29 +0300
Subject: [PATCH] Find MUMPS before linking
---
CMakeLists.txt | 5 +++--
cmake/FindMUMPS.cmake | 14 ++++++++++++++
2 files changed, 17 insertions(+), 2 deletions(-)
create mode 100644 cmake/FindMUMPS.cmake
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 90eed8bd..f95c4ac2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -82,13 +82,14 @@ if(GMSH_FOUND)
endif()
find_package(METIS)
-
if(METIS_FOUND)
target_link_libraries(sparselizard PUBLIC METIS::METIS)
target_compile_definitions(sparselizard PRIVATE -DHAVE_METIS)
endif()
-target_link_libraries(sparselizard PUBLIC cmumps)
+find_package(MUMPS REQUIRED)
+target_link_libraries(sparselizard PUBLIC MUMPS::MUMPS)
+
target_compile_definitions(sparselizard PRIVATE
-DHAVE_BLAS
-DHAVE_MPI
diff --git a/cmake/FindMUMPS.cmake b/cmake/FindMUMPS.cmake
new file mode 100644
index 00000000..7bc0e5ba
--- /dev/null
+++ b/cmake/FindMUMPS.cmake
@@ -0,0 +1,14 @@
+include(FindPackageHandleStandardArgs)
+
+find_library(MUMPS_LIBRARY NAMES cmumps)
+
+find_package_handle_standard_args(MUMPS DEFAULT_MSG MUMPS_LIBRARY)
+
+if(MUMPS_FOUND)
+ mark_as_advanced(MUMPS_LIBRARY)
+endif()
+
+IF(MUMPS_FOUND AND NOT TARGET MUMPS::MUMPS)
+ add_library(MUMPS::MUMPS IMPORTED SHARED)
+ set_property(TARGET MUMPS::MUMPS PROPERTY IMPORTED_LOCATION ${MUMPS_LIBRARY})
+endif()
--
2.35.3