From fb7ca870893d41c2b07fa3e0aece4af9cd818f8b Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Thu, 17 Feb 2022 10:12:26 +0000
Subject: [PATCH] [cmake] Added option OGS_EIGEN_USE_MKL.

Adds define EIGEN_USE_MKL_ALL, see
https://eigen.tuxfamily.org/dox/TopicUsingIntelMKL.html.
---
 CMakeLists.txt         | 4 ++++
 MathLib/CMakeLists.txt | 7 ++++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 25bcdffeb3e..d84783484e6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -154,6 +154,10 @@ else()
         ${OGS_EIGEN_DYNAMIC_SHAPE_MATRICES}
     )
 endif()
+
+cmake_dependent_option(
+    OGS_EIGEN_USE_MKL "Defines EIGEN_USE_MKL_ALL." OFF "OGS_USE_MKL" OFF
+)
 # Eigen End
 
 # Debug
diff --git a/MathLib/CMakeLists.txt b/MathLib/CMakeLists.txt
index 68c1dfb6e78..84ca68493ff 100644
--- a/MathLib/CMakeLists.txt
+++ b/MathLib/CMakeLists.txt
@@ -40,10 +40,10 @@ if(OGS_USE_LIS)
     target_include_directories(MathLib PUBLIC ${LIS_INCLUDE_DIR})
 endif()
 if(OGS_USE_MKL)
-    target_include_directories(MathLib PRIVATE ${MKL_INCLUDE_DIR})
-    target_link_libraries(MathLib PRIVATE ${MKL_LIBRARIES})
+    target_include_directories(MathLib PUBLIC ${MKL_INCLUDE_DIR})
+    target_link_libraries(MathLib PUBLIC ${MKL_LIBRARIES})
     target_link_options(MathLib PUBLIC ${MKL_LINK_FLAGS})
-    target_compile_definitions(MathLib PRIVATE ${MKL_DEFINITIONS})
+    target_compile_definitions(MathLib PUBLIC ${MKL_DEFINITIONS})
 endif()
 
 target_compile_definitions(
@@ -57,5 +57,6 @@ target_compile_definitions(
         $<$<BOOL:${OGS_USE_EIGEN_UNSUPPORTED}>:USE_EIGEN_UNSUPPORTED>
         $<$<BOOL:${OGS_EIGEN_INITIALIZE_MATRICES_BY_NAN}>:EIGEN_INITIALIZE_MATRICES_BY_NAN>
         $<$<CONFIG:Debug>:EIGEN_INITIALIZE_MATRICES_BY_NAN>
+        $<$<AND:$<BOOL:${OGS_USE_MKL}>,$<BOOL:${OGS_EIGEN_USE_MKL}>>:EIGEN_USE_MKL_ALL>
     PRIVATE $<$<BOOL:${OGS_USE_MKL}>:USE_MKL>
 )
-- 
GitLab