From 8e47d1cd24ad00ee6b2e8ef1e25b0b2fa03e34d3 Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Tue, 7 Mar 2023 14:19:27 +0100
Subject: [PATCH] [cmake] Fixed petsc detection when PETSC_LIBRARIES contains
 more than one lib.

E.g. when building with --download-hypre.
---
 scripts/cmake/DependenciesExternalProject.cmake | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/scripts/cmake/DependenciesExternalProject.cmake b/scripts/cmake/DependenciesExternalProject.cmake
index c4fb852303f..3613d4e8a5a 100644
--- a/scripts/cmake/DependenciesExternalProject.cmake
+++ b/scripts/cmake/DependenciesExternalProject.cmake
@@ -162,7 +162,9 @@ if(OGS_USE_PETSC)
 
     add_library(petsc SHARED IMPORTED)
     target_include_directories(petsc INTERFACE ${PETSC_INCLUDES})
-    set_target_properties(petsc PROPERTIES IMPORTED_LOCATION ${PETSC_LIBRARIES})
+    # Get first petsc lib as import location
+    list(GET PETSC_LIBRARIES 0 _first_petsc_lib)
+    set_target_properties(petsc PROPERTIES IMPORTED_LOCATION ${_first_petsc_lib})
     target_compile_definitions(petsc INTERFACE USE_PETSC)
 endif()
 
-- 
GitLab