From 3b6c380d637aa6e2022613b837a31c5f6fe502c5 Mon Sep 17 00:00:00 2001
From: mbellgardt <bellgardt@vr.rwth-aachen.de>
Date: Fri, 12 Feb 2021 11:13:03 +0100
Subject: [PATCH] Make nDisplay only a dependency under Windows or Linux

---
 Source/UniversalLogging/Private/UniversalLogging.cpp | 10 ++++++++++
 Source/UniversalLogging/Public/IUniversalLogging.h   |  3 +++
 Source/UniversalLogging/UniversalLogging.Build.cs    |  7 ++++++-
 UniversalLogging.uplugin                             |  6 +++++-
 4 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/Source/UniversalLogging/Private/UniversalLogging.cpp b/Source/UniversalLogging/Private/UniversalLogging.cpp
index 873db43..8f09ac6 100644
--- a/Source/UniversalLogging/Private/UniversalLogging.cpp
+++ b/Source/UniversalLogging/Private/UniversalLogging.cpp
@@ -3,8 +3,10 @@
 #include "LogStream.h"
 #include "GameFramework/PlayerController.h"
 #include "GameFramework/HUD.h"
+#if PLATFORM_WINDOWS || PLATFORM_LINUX
 #include "IDisplayCluster.h"
 #include "Cluster/IDisplayClusterClusterManager.h"
+#endif
 #include "Misc/CommandLine.h"
 
 void UniversalLoggingImpl::StartupModule()
@@ -154,6 +156,7 @@ void UniversalLoggingImpl::ResetSessionId(FString Prefix)
 
 bool UniversalLoggingImpl::IsClusterMaster()
 {
+#if PLATFORM_WINDOWS || PLATFORM_LINUX
   if (!IDisplayCluster::IsAvailable()) 
   {
      return true;
@@ -164,14 +167,21 @@ bool UniversalLoggingImpl::IsClusterMaster()
     return true; // if we are not in cluster mode, we are always the master
   }
   return Manager->IsMaster() || !Manager->IsSlave();
+#else
+  return true;
+#endif
 }
 
 FString UniversalLoggingImpl::GetNodeName()
 {
+#if PLATFORM_WINDOWS || PLATFORM_LINUX
   if (IDisplayCluster::Get().GetOperationMode() == EDisplayClusterOperationMode::Cluster)
     return IDisplayCluster::Get().GetClusterMgr()->GetNodeId();
   else 
     return FString(TEXT("Localhost"));
+#else
+	return FString(TEXT("Localhost"));
+#endif
 }
 
 IMPLEMENT_MODULE(UniversalLoggingImpl, UniversalLogging)
diff --git a/Source/UniversalLogging/Public/IUniversalLogging.h b/Source/UniversalLogging/Public/IUniversalLogging.h
index a08dd4b..b76c7ec 100644
--- a/Source/UniversalLogging/Public/IUniversalLogging.h
+++ b/Source/UniversalLogging/Public/IUniversalLogging.h
@@ -1,6 +1,9 @@
 #pragma once
 
+#if PLATFORM_WINDOWS || PLATFORM_LINUX
 #include "IDisplayCluster.h"
+#endif
+
 #include "Modules/ModuleManager.h"
 
 #include "ILogStream.h"
diff --git a/Source/UniversalLogging/UniversalLogging.Build.cs b/Source/UniversalLogging/UniversalLogging.Build.cs
index 7b3353a..df6cdf3 100644
--- a/Source/UniversalLogging/UniversalLogging.Build.cs
+++ b/Source/UniversalLogging/UniversalLogging.Build.cs
@@ -12,6 +12,11 @@ public class UniversalLogging : ModuleRules
         PrivateIncludePaths.AddRange(new string[] {  });
         PublicIncludePaths.AddRange(new string[] {  });
 
-        PublicDependencyModuleNames.AddRange(new string[] { "CoreUObject", "Engine", "Core", "DisplayCluster" });
+        PublicDependencyModuleNames.AddRange(new string[] { "CoreUObject", "Engine", "Core" });
+        
+        if (Target.Platform == UnrealTargetPlatform.Linux || Target.Platform == UnrealTargetPlatform.Win64)
+        {
+            PublicDependencyModuleNames.AddRange(new string[] { "DisplayCluster" });
+        }
     }
 }
\ No newline at end of file
diff --git a/UniversalLogging.uplugin b/UniversalLogging.uplugin
index dd492a5..1a06157 100644
--- a/UniversalLogging.uplugin
+++ b/UniversalLogging.uplugin
@@ -20,7 +20,11 @@
   "Plugins": [
     {
       "Name": "nDisplay",
-      "Enabled": true
+      "Enabled": true,
+      "WhitelistPlatforms": [
+        "Win64",
+        "Linux"
+      ]
     }
   ]
 }
\ No newline at end of file
-- 
GitLab