diff --git a/.oppfeatures b/.oppfeatures
index 913dfb6f682..324860018e0 100644
--- a/.oppfeatures
+++ b/.oppfeatures
@@ -1866,21 +1866,6 @@
compileFlags = ""
linkerFlags = ""
/>
-
#include
@@ -149,3 +151,4 @@ std::string SelfDoc::gateInfo(cGate *gate)
} // namespace inet
+#endif // INET_WITH_SELFDOC
diff --git a/src/inet/common/selfdoc/SelfDoc.h b/src/inet/common/selfdoc/SelfDoc.h
index 45f24296399..e59867ac306 100644
--- a/src/inet/common/selfdoc/SelfDoc.h
+++ b/src/inet/common/selfdoc/SelfDoc.h
@@ -9,6 +9,8 @@
#ifndef __INET_SELFDOC_H
#define __INET_SELFDOC_H
+#ifdef INET_WITH_SELFDOC
+
namespace inet {
class INET_API SelfDoc
@@ -61,7 +63,7 @@ class INET_API SelfDocTempOffClass
#endif
#define __Enter_Method_SelfDoc(...) \
- if (SelfDoc::notInInitialize(__VA_ARGS__) && (__GET_SIMULATION()->__CSIMULATION_GET_SIMULATION_STAGE() != STAGE(CLEANUP))) { \
+ if (SelfDoc::generateSelfdoc && SelfDoc::notInInitialize(__VA_ARGS__) && (__GET_SIMULATION()->__CSIMULATION_GET_SIMULATION_STAGE() != STAGE(CLEANUP))) { \
auto __from = __ctx.getCallerContext(); \
std::string fromModuleName = __from ? __from->getParentModule() ? __from->getComponentType()->getFullName() : "-=Network=-" : "-=unknown=-"; \
std::string toModuleName = __GET_SIMULATION()->getContext()->getComponentType()->getFullName(); \
@@ -97,3 +99,4 @@ class INET_API SelfDocTempOffClass
#endif
+#endif
diff --git a/src/inet/common/selfdoc/SelfDocumenterFingerprintCalculator.cc b/src/inet/common/selfdoc/SelfDocumenterFingerprintCalculator.cc
index 29cd05b3e86..404884c93f3 100644
--- a/src/inet/common/selfdoc/SelfDocumenterFingerprintCalculator.cc
+++ b/src/inet/common/selfdoc/SelfDocumenterFingerprintCalculator.cc
@@ -2,6 +2,7 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
//
+#ifdef INET_WITH_SELFDOC
#include "inet/common/selfdoc/SelfDocumenterFingerprintCalculator.h"
@@ -100,3 +101,4 @@ void SelfDocumenterFingerprintCalculator::addEvent(cEvent *event)
} // namespace
+#endif // INET_WITH_SELFDOC
diff --git a/src/inet/common/selfdoc/SelfDocumenterFingerprintCalculator.h b/src/inet/common/selfdoc/SelfDocumenterFingerprintCalculator.h
index 612afcc7ecd..d8102c9428d 100644
--- a/src/inet/common/selfdoc/SelfDocumenterFingerprintCalculator.h
+++ b/src/inet/common/selfdoc/SelfDocumenterFingerprintCalculator.h
@@ -5,6 +5,8 @@
#ifndef __INET_SELFDOCUMENTERFINGERPRINTCALCULATOR_H
#define __INET_SELFDOCUMENTERFINGERPRINTCALCULATOR_H
+#ifdef INET_WITH_SELFDOC
+
#include "inet/common/INETDefs.h"
namespace inet {
@@ -21,3 +23,4 @@ class INET_API SelfDocumenterFingerprintCalculator : public cSingleFingerprintCa
#endif
+#endif