From dd28873b29274b80f81e08b8538ea587d25ef012 Mon Sep 17 00:00:00 2001
From: Dmitri Naumov <dmitri.naumov@ufz.de>
Date: Thu, 28 Feb 2019 17:52:45 +0100
Subject: [PATCH] Add OGS_USE_MFRONT definition.

---
 CMakeLists.txt                                |  4 +++-
 .../CreateConstitutiveRelation.cpp            |  8 +++++++
 .../SolidModels/MFront/CreateMFront.cpp       | 24 -------------------
 3 files changed, 11 insertions(+), 25 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d998bdb9fc5..1774c94b3ca 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -255,7 +255,9 @@ endif()
 option(OGS_USE_MFRONT
        "Enable solid material models by MFront (https://tfel.sourceforge.net)"
        OFF)
-
+if(OGS_USE_MFRONT)
+    add_definitions(-DOGS_USE_MFRONT)
+endif()
 # ---- Definitions ----
 if(OGS_USE_LIS)
     add_definitions(-DUSE_LIS)
diff --git a/MaterialLib/SolidModels/CreateConstitutiveRelation.cpp b/MaterialLib/SolidModels/CreateConstitutiveRelation.cpp
index 17a786b9405..be94fe171f7 100644
--- a/MaterialLib/SolidModels/CreateConstitutiveRelation.cpp
+++ b/MaterialLib/SolidModels/CreateConstitutiveRelation.cpp
@@ -16,7 +16,9 @@
 #include "CreateLinearElasticIsotropic.h"
 #include "CreateLinearElasticOrthotropic.h"
 #include "CreateLubby2.h"
+#ifdef OGS_USE_MFRONT
 #include "MFront/CreateMFront.h"
+#endif  // OGS_USE_MFRONT
 
 #include "MechanicsBase.h"
 
@@ -71,8 +73,14 @@ createConstitutiveRelation(
     }
     if (type == "MFront")
     {
+#ifdef OGS_USE_MFRONT
         return MaterialLib::Solids::MFront::createMFront<DisplacementDim>(
             parameters, config);
+#else   // OGS_USE_MFRONT
+        OGS_FATAL(
+            "OGS is compiled without MFront support. See OGS_USE_MFRONT CMake "
+            "option.");
+#endif  // OGS_USE_MFRONT
     }
     OGS_FATAL("Cannot construct constitutive relation of given type '%s'.",
               type.c_str());
diff --git a/MaterialLib/SolidModels/MFront/CreateMFront.cpp b/MaterialLib/SolidModels/MFront/CreateMFront.cpp
index 97446167c46..c4af60b0fbb 100644
--- a/MaterialLib/SolidModels/MFront/CreateMFront.cpp
+++ b/MaterialLib/SolidModels/MFront/CreateMFront.cpp
@@ -9,8 +9,6 @@
 
 #include "CreateMFront.h"
 
-#ifdef OGS_USE_MFRONT
-
 #include "BaseLib/FileTools.h"
 #include "ParameterLib/Utils.h"
 
@@ -182,28 +180,6 @@ std::unique_ptr<MechanicsBase<DisplacementDim>> createMFront(
 }  // namespace Solids
 }  // namespace MaterialLib
 
-#else  // OGS_USE_MFRONT
-
-namespace MaterialLib
-{
-namespace Solids
-{
-namespace MFront
-{
-template <int DisplacementDim>
-std::unique_ptr<MechanicsBase<DisplacementDim>> createMFront(
-    std::vector<
-        std::unique_ptr<ParameterLib::ParameterBase>> const& /*parameters*/,
-    BaseLib::ConfigTree const& /*config*/)
-{
-    OGS_FATAL("OpenGeoSys has not been build with MFront support.");
-}
-}  // namespace MFront
-}  // namespace Solids
-}  // namespace MaterialLib
-
-#endif  // OGS_USE_MFRONT
-
 namespace MaterialLib
 {
 namespace Solids
-- 
GitLab