diff --git a/CMakeLists.txt b/CMakeLists.txt
index d998bdb9fc5be797b888a11ad75462657815fa79..1774c94b3ca2973f6185e01fce2fc83b9ee89c77 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 17a786b940597932b1600ceaaf614c959a50fe85..be94fe171f77e266a8be004252f68242409ffc9b 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 97446167c46e28f6e5408233cdc9f3806f12bb17..c4af60b0fbb9aaaf60b37d21d3524d8a919eb7b3 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