From 92155ff98c0201d6bf9f9baf6eb2e40d93a36b0f Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Fri, 7 May 2021 11:52:07 +0200
Subject: [PATCH] [cm] Moved eigen defines into MathLib.

---
 CMakeLists.txt         | 21 ---------------------
 MathLib/CMakeLists.txt | 12 ++++++++++--
 2 files changed, 10 insertions(+), 23 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 34e7211edf8..76d609cd275 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -186,27 +186,6 @@ option(OGS_USE_MFRONT
        "Enable solid material models by MFront (https://tfel.sourceforge.net)"
        OFF
 )
-# ---- Definitions ----
-
-# Eigen
-if(CMAKE_BUILD_TYPE STREQUAL "Debug")
-    add_definitions(-DEIGEN_INITIALIZE_MATRICES_BY_NAN)
-endif()
-if(EIGEN_NO_DEBUG)
-    add_definitions(-DEIGEN_NO_DEBUG)
-endif()
-if(EIGEN_DONT_VECTORIZE)
-    add_definitions(-DEIGEN_DONT_VECTORIZE)
-endif()
-if(OGS_EIGEN_DYNAMIC_SHAPE_MATRICES_INTERNAL)
-    add_definitions(-DOGS_EIGEN_DYNAMIC_SHAPE_MATRICES)
-endif()
-if(OGS_USE_EIGEN_UNSUPPORTED)
-    add_definitions(-DUSE_EIGEN_UNSUPPORTED)
-endif()
-if(OGS_EIGEN_INITIALIZE_MATRICES_BY_NAN)
-    add_definitions(-DEIGEN_INITIALIZE_MATRICES_BY_NAN)
-endif()
 
 # Packaging
 include(scripts/cmake/packaging/Pack.cmake)
diff --git a/MathLib/CMakeLists.txt b/MathLib/CMakeLists.txt
index a6417a29849..224123d70f3 100644
--- a/MathLib/CMakeLists.txt
+++ b/MathLib/CMakeLists.txt
@@ -53,7 +53,15 @@ endif()
 
 target_compile_definitions(
     MathLib
-    PUBLIC $<$<BOOL:${USE_LIS}>:USE_LIS> $<$<BOOL:${OGS_USE_PETSC}>:USE_PETSC>
-           $<$<BOOL:${OGS_USE_CVODE}>:CVODE_FOUND>
+    PUBLIC
+        $<$<BOOL:${USE_LIS}>:USE_LIS>
+        $<$<BOOL:${OGS_USE_PETSC}>:USE_PETSC>
+        $<$<BOOL:${OGS_USE_CVODE}>:CVODE_FOUND>
+        $<$<BOOL:${EIGEN_NO_DEBUG}>:EIGEN_NO_DEBUG>
+        $<$<BOOL:${EIGEN_DONT_VECTORIZE}>:EIGEN_DONT_VECTORIZE>
+        $<$<BOOL:${OGS_EIGEN_DYNAMIC_SHAPE_MATRICES_INTERNAL}>:OGS_EIGEN_DYNAMIC_SHAPE_MATRICES>
+        $<$<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>
     PRIVATE $<$<BOOL:${OGS_USE_MKL}>:USE_MKL>
 )
-- 
GitLab