Enforced IWYU-style PCH model:

- Removed explicit PCH.
- Fixed includes to compile for all supported engine versions, including non-unity builds.
- Configured build.cs to treat ImGui as an engine module and added stricter compilation rules.
This commit is contained in:
Sebastian 2020-06-25 10:52:46 +01:00
parent ac2b80bd63
commit d4ffe9443f
39 changed files with 40 additions and 85 deletions

View File

@ -13,7 +13,7 @@ Version: 1.20
ImGui version: 1.74 ImGui version: 1.74
Supported engine version: 4.24* Supported engine version: 4.25*
\* *Plugin has been tested and if necessary updated to compile and work with this engine version. As long as possible I will try to maintain backward compatibility of existing features and possibly but not necessarily when adding new features. Right now it should be at least backward compatible with the engine version 4.15.* \* *Plugin has been tested and if necessary updated to compile and work with this engine version. As long as possible I will try to maintain backward compatibility of existing features and possibly but not necessarily when adding new features. Right now it should be at least backward compatible with the engine version 4.15.*

View File

@ -23,10 +23,12 @@ public class ImGui : ModuleRules
// Enable runtime loader, if you want this module to be automatically loaded in runtime builds (monolithic). // Enable runtime loader, if you want this module to be automatically loaded in runtime builds (monolithic).
bool bEnableRuntimeLoader = true; bool bEnableRuntimeLoader = true;
PCHUsage = PCHUsageMode.UseSharedPCHs; PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
#if UE_4_21_OR_LATER #if UE_4_24_OR_LATER
PrivatePCHHeaderFile = "Private/ImGuiPrivatePCH.h"; bLegacyPublicIncludePaths = false;
ShadowVariableWarningLevel = WarningLevel.Error;
bTreatAsEngineModule = true;
#endif #endif
PublicIncludePaths.AddRange( PublicIncludePaths.AddRange(

View File

@ -1,11 +1,9 @@
// Distributed under the MIT License (MIT) (see accompanying LICENSE file) // Distributed under the MIT License (MIT) (see accompanying LICENSE file)
#include "ImGuiPrivatePCH.h" #include "ImGuiCanvasSizeInfoCustomization.h"
#if WITH_EDITOR #if WITH_EDITOR
#include "ImGuiCanvasSizeInfoCustomization.h"
#include "ImGuiModuleSettings.h" #include "ImGuiModuleSettings.h"
#include <PropertyCustomizationHelpers.h> #include <PropertyCustomizationHelpers.h>

View File

@ -1,11 +1,9 @@
// Distributed under the MIT License (MIT) (see accompanying LICENSE file) // Distributed under the MIT License (MIT) (see accompanying LICENSE file)
#include "ImGuiPrivatePCH.h" #include "ImGuiEditor.h"
#if WITH_EDITOR #if WITH_EDITOR
#include "ImGuiEditor.h"
#include "ImGuiCanvasSizeInfoCustomization.h" #include "ImGuiCanvasSizeInfoCustomization.h"
#include "ImGuiKeyInfoCustomization.h" #include "ImGuiKeyInfoCustomization.h"
#include "ImGuiModuleSettings.h" #include "ImGuiModuleSettings.h"

View File

@ -1,11 +1,9 @@
// Distributed under the MIT License (MIT) (see accompanying LICENSE file) // Distributed under the MIT License (MIT) (see accompanying LICENSE file)
#include "ImGuiPrivatePCH.h" #include "ImGuiKeyInfoCustomization.h"
#if WITH_EDITOR #if WITH_EDITOR
#include "ImGuiKeyInfoCustomization.h"
#include "ImGuiModuleSettings.h" #include "ImGuiModuleSettings.h"
#include <PropertyCustomizationHelpers.h> #include <PropertyCustomizationHelpers.h>

View File

@ -1,7 +1,5 @@
// Distributed under the MIT License (MIT) (see accompanying LICENSE file) // Distributed under the MIT License (MIT) (see accompanying LICENSE file)
#include "ImGuiPrivatePCH.h"
#include "ImGuiContextManager.h" #include "ImGuiContextManager.h"
#include "ImGuiDelegatesContainer.h" #include "ImGuiDelegatesContainer.h"

View File

@ -3,6 +3,7 @@
#pragma once #pragma once
#include "ImGuiContextProxy.h" #include "ImGuiContextProxy.h"
#include "VersionCompatibility.h"
class FImGuiModuleSettings; class FImGuiModuleSettings;

View File

@ -1,13 +1,12 @@
// Distributed under the MIT License (MIT) (see accompanying LICENSE file) // Distributed under the MIT License (MIT) (see accompanying LICENSE file)
#include "ImGuiPrivatePCH.h"
#include "ImGuiContextProxy.h" #include "ImGuiContextProxy.h"
#include "ImGuiDelegatesContainer.h" #include "ImGuiDelegatesContainer.h"
#include "ImGuiImplementation.h" #include "ImGuiImplementation.h"
#include "ImGuiInteroperability.h" #include "ImGuiInteroperability.h"
#include "Utilities/Arrays.h" #include "Utilities/Arrays.h"
#include "VersionCompatibility.h"
#include <GenericPlatform/GenericPlatformFile.h> #include <GenericPlatform/GenericPlatformFile.h>
#include <Misc/Paths.h> #include <Misc/Paths.h>

View File

@ -1,7 +1,5 @@
// Distributed under the MIT License (MIT) (see accompanying LICENSE file) // Distributed under the MIT License (MIT) (see accompanying LICENSE file)
#include "ImGuiPrivatePCH.h"
#include "ImGuiDelegates.h" #include "ImGuiDelegates.h"
#include "ImGuiDelegatesContainer.h" #include "ImGuiDelegatesContainer.h"

View File

@ -1,7 +1,5 @@
// Distributed under the MIT License (MIT) (see accompanying LICENSE file) // Distributed under the MIT License (MIT) (see accompanying LICENSE file)
#include "ImGuiPrivatePCH.h"
#include "ImGuiDelegatesContainer.h" #include "ImGuiDelegatesContainer.h"
#include "Utilities/WorldContextIndex.h" #include "Utilities/WorldContextIndex.h"

View File

@ -1,8 +1,7 @@
// Distributed under the MIT License (MIT) (see accompanying LICENSE file) // Distributed under the MIT License (MIT) (see accompanying LICENSE file)
#include "ImGuiPrivatePCH.h"
#include "ImGuiDemo.h" #include "ImGuiDemo.h"
#include "ImGuiModuleProperties.h" #include "ImGuiModuleProperties.h"
#include <CoreGlobals.h> #include <CoreGlobals.h>

View File

@ -2,6 +2,8 @@
#pragma once #pragma once
#include <CoreMinimal.h>
#include <imgui.h> #include <imgui.h>
class FImGuiModuleProperties; class FImGuiModuleProperties;

View File

@ -1,7 +1,5 @@
// Distributed under the MIT License (MIT) (see accompanying LICENSE file) // Distributed under the MIT License (MIT) (see accompanying LICENSE file)
#include "ImGuiPrivatePCH.h"
#include "ImGuiDrawData.h" #include "ImGuiDrawData.h"

View File

@ -3,6 +3,7 @@
#pragma once #pragma once
#include "ImGuiInteroperability.h" #include "ImGuiInteroperability.h"
#include "VersionCompatibility.h"
#include <Rendering/RenderingCommon.h> #include <Rendering/RenderingCommon.h>

View File

@ -1,12 +1,10 @@
// Distributed under the MIT License (MIT) (see accompanying LICENSE file) // Distributed under the MIT License (MIT) (see accompanying LICENSE file)
#include "ImGuiPrivatePCH.h" #include "ImGuiImplementation.h"
// We build ImGui source code as part of this module. This is for convenience (no need to manually build libraries for #include <CoreMinimal.h>
// different target platforms) but it also exposes the whole ImGui source for inspection, which can be pretty handy.
// Source files are included from Third Party directory, so we can wrap them in required by Unreal Build System headers // For convenience and easy access to the ImGui source code, we build it as part of this module.
// without modifications in ImGui source code.
//
// We don't need to define IMGUI_API manually because it is already done for this module. // We don't need to define IMGUI_API manually because it is already done for this module.
#if PLATFORM_XBOXONE #if PLATFORM_XBOXONE
@ -20,8 +18,6 @@
#endif // PLATFORM_WINDOWS #endif // PLATFORM_WINDOWS
#if WITH_EDITOR #if WITH_EDITOR
#include "imgui.h"
// Global ImGui context pointer. // Global ImGui context pointer.
ImGuiContext* GImGuiContextPtr = nullptr; ImGuiContext* GImGuiContextPtr = nullptr;
// Handle to the global ImGui context pointer. // Handle to the global ImGui context pointer.

View File

@ -2,8 +2,7 @@
#pragma once #pragma once
#include <imgui.h> struct ImGuiContext;
// Gives access to selected ImGui implementation features. // Gives access to selected ImGui implementation features.
namespace ImGuiImplementation namespace ImGuiImplementation

View File

@ -1,17 +1,18 @@
// Distributed under the MIT License (MIT) (see accompanying LICENSE file) // Distributed under the MIT License (MIT) (see accompanying LICENSE file)
#include "ImGuiPrivatePCH.h"
#include "ImGuiInputHandler.h" #include "ImGuiInputHandler.h"
#include "ImGuiContextProxy.h" #include "ImGuiContextProxy.h"
#include "ImGuiInputState.h" #include "ImGuiInputState.h"
#include "ImGuiModuleDebug.h"
#include "ImGuiModuleManager.h" #include "ImGuiModuleManager.h"
#include "ImGuiModuleSettings.h" #include "ImGuiModuleSettings.h"
#include "VersionCompatibility.h"
#include <Engine/Console.h> #include <Engine/Console.h>
#include <Framework/Application/SlateApplication.h> #include <Framework/Application/SlateApplication.h>
#include <GameFramework/InputSettings.h> #include <GameFramework/InputSettings.h>
#include <InputCoreTypes.h>
#include <Input/Events.h> #include <Input/Events.h>
#if WITH_EDITOR #if WITH_EDITOR

View File

@ -1,11 +1,12 @@
// Distributed under the MIT License (MIT) (see accompanying LICENSE file) // Distributed under the MIT License (MIT) (see accompanying LICENSE file)
#include "ImGuiPrivatePCH.h"
#include "ImGuiInputHandlerFactory.h" #include "ImGuiInputHandlerFactory.h"
#include "ImGuiInputHandler.h" #include "ImGuiInputHandler.h"
#include "ImGuiModuleDebug.h"
#include <Engine/GameViewportClient.h> #include <Engine/GameViewportClient.h>
#include <InputCoreTypes.h>
UImGuiInputHandler* FImGuiInputHandlerFactory::NewHandler(const FStringClassReference& HandlerClassReference, FImGuiModuleManager* ModuleManager, UGameViewportClient* GameViewport, int32 ContextIndex) UImGuiInputHandler* FImGuiInputHandlerFactory::NewHandler(const FStringClassReference& HandlerClassReference, FImGuiModuleManager* ModuleManager, UGameViewportClient* GameViewport, int32 ContextIndex)

View File

@ -1,7 +1,5 @@
// Distributed under the MIT License (MIT) (see accompanying LICENSE file) // Distributed under the MIT License (MIT) (see accompanying LICENSE file)
#include "ImGuiPrivatePCH.h"
#include "ImGuiInputState.h" #include "ImGuiInputState.h"
#include <algorithm> #include <algorithm>

View File

@ -1,8 +1,7 @@
// Distributed under the MIT License (MIT) (see accompanying LICENSE file) // Distributed under the MIT License (MIT) (see accompanying LICENSE file)
#include "ImGuiPrivatePCH.h"
#include "ImGuiInteroperability.h" #include "ImGuiInteroperability.h"
#include "ImGuiInputState.h" #include "ImGuiInputState.h"
#include "Utilities/Arrays.h" #include "Utilities/Arrays.h"

View File

@ -1,7 +1,5 @@
// Distributed under the MIT License (MIT) (see accompanying LICENSE file) // Distributed under the MIT License (MIT) (see accompanying LICENSE file)
#include "ImGuiPrivatePCH.h"
#include "ImGuiModule.h" #include "ImGuiModule.h"
#include "ImGuiDelegatesContainer.h" #include "ImGuiDelegatesContainer.h"

View File

@ -1,10 +1,8 @@
// Distributed under the MIT License (MIT) (see accompanying LICENSE file) // Distributed under the MIT License (MIT) (see accompanying LICENSE file)
#include "ImGuiPrivatePCH.h"
#include "ImGuiModuleCommands.h" #include "ImGuiModuleCommands.h"
#include "ImGuiModuleProperties.h"
#include "ImGuiModuleProperties.h"
#include "Utilities/DebugExecBindings.h" #include "Utilities/DebugExecBindings.h"

View File

@ -1,7 +1,5 @@
// Distributed under the MIT License (MIT) (see accompanying LICENSE file) // Distributed under the MIT License (MIT) (see accompanying LICENSE file)
#include "ImGuiPrivatePCH.h"
#include "ImGuiModuleManager.h" #include "ImGuiModuleManager.h"
#include "ImGuiInteroperability.h" #include "ImGuiInteroperability.h"

View File

@ -1,15 +1,13 @@
// Distributed under the MIT License (MIT) (see accompanying LICENSE file) // Distributed under the MIT License (MIT) (see accompanying LICENSE file)
#include "ImGuiPrivatePCH.h"
#include "ImGuiModuleSettings.h" #include "ImGuiModuleSettings.h"
#include "ImGuiModuleCommands.h" #include "ImGuiModuleCommands.h"
#include "ImGuiModuleProperties.h" #include "ImGuiModuleProperties.h"
#include <ConfigCacheIni.h>
#include <Engine/Engine.h> #include <Engine/Engine.h>
#include <GameFramework/GameUserSettings.h> #include <GameFramework/GameUserSettings.h>
#include <Misc/ConfigCacheIni.h>
//==================================================================================================== //====================================================================================================

View File

@ -4,9 +4,10 @@
#include "VersionCompatibility.h" #include "VersionCompatibility.h"
#include <SlateTypes.h>
#include <Curves/CurveFloat.h> #include <Curves/CurveFloat.h>
#include <Delegates/Delegate.h> #include <Delegates/Delegate.h>
#include <InputCoreTypes.h>
#include <Styling/SlateTypes.h>
#include <UObject/Object.h> #include <UObject/Object.h>
// We use FStringClassReference, which is supported by older and newer engine versions. Starting from 4.18, it is // We use FStringClassReference, which is supported by older and newer engine versions. Starting from 4.18, it is

View File

@ -1,15 +0,0 @@
// Distributed under the MIT License (MIT) (see accompanying LICENSE file)
// Module-wide macros
#include "VersionCompatibility.h"
#include "ImGuiModuleDebug.h"
// Module
#include "ImGuiModule.h"
// Engine
#include <CoreMinimal.h>
#include <Engine/Engine.h>
// You should place include statements to your module's private header files here. You only need to
// add includes for headers that are used in most of your module's source files though.

View File

@ -1,7 +1,5 @@
// Distributed under the MIT License (MIT) (see accompanying LICENSE file) // Distributed under the MIT License (MIT) (see accompanying LICENSE file)
#include "ImGuiPrivatePCH.h"
#include "ImGuiTextureHandle.h" #include "ImGuiTextureHandle.h"
#include "ImGuiInteroperability.h" #include "ImGuiInteroperability.h"

View File

@ -1,7 +1,5 @@
// Distributed under the MIT License (MIT) (see accompanying LICENSE file) // Distributed under the MIT License (MIT) (see accompanying LICENSE file)
#include "ImGuiPrivatePCH.h"
#include "TextureManager.h" #include "TextureManager.h"
#include <Engine/Texture2D.h> #include <Engine/Texture2D.h>

View File

@ -4,6 +4,7 @@
#include <Styling/SlateBrush.h> #include <Styling/SlateBrush.h>
#include <Textures/SlateShaderResource.h> #include <Textures/SlateShaderResource.h>
#include <UObject/WeakObjectPtr.h>
class UTexture2D; class UTexture2D;

View File

@ -1,8 +1,7 @@
// Distributed under the MIT License (MIT) (see accompanying LICENSE file) // Distributed under the MIT License (MIT) (see accompanying LICENSE file)
#include "ImGuiPrivatePCH.h"
#include "DebugExecBindings.h" #include "DebugExecBindings.h"
#include "ImGuiModuleSettings.h" #include "ImGuiModuleSettings.h"
#include <GameFramework/PlayerInput.h> #include <GameFramework/PlayerInput.h>

View File

@ -2,6 +2,7 @@
#pragma once #pragma once
class FString;
struct FImGuiKeyInfo; struct FImGuiKeyInfo;
namespace DebugExecBindings namespace DebugExecBindings

View File

@ -1,7 +1,5 @@
// Distributed under the MIT License (MIT) (see accompanying LICENSE file) // Distributed under the MIT License (MIT) (see accompanying LICENSE file)
#include "ImGuiPrivatePCH.h"
#include "WorldContext.h" #include "WorldContext.h"

View File

@ -2,10 +2,10 @@
#pragma once #pragma once
#include <CoreMinimal.h>
#include <Engine/Engine.h> #include <Engine/Engine.h>
#include <Engine/GameInstance.h> #include <Engine/GameInstance.h>
#include <Engine/GameViewportClient.h> #include <Engine/GameViewportClient.h>
#include <UObject/WeakObjectPtr.h>
// Utilities helping to get a World Context. // Utilities helping to get a World Context.

View File

@ -1,9 +1,9 @@
// Distributed under the MIT License (MIT) (see accompanying LICENSE file) // Distributed under the MIT License (MIT) (see accompanying LICENSE file)
#include "ImGuiPrivatePCH.h"
#include "SImGuiCanvasControl.h" #include "SImGuiCanvasControl.h"
#include "VersionCompatibility.h"
#include <Rendering/DrawElements.h> #include <Rendering/DrawElements.h>
#include <SlateOptMacros.h> #include <SlateOptMacros.h>

View File

@ -3,7 +3,6 @@
#pragma once #pragma once
#include "ImGuiInputState.h" #include "ImGuiInputState.h"
#include "ImGuiModuleDebug.h"
#include "ImGuiModuleSettings.h" #include "ImGuiModuleSettings.h"
#include <Brushes/SlateBorderBrush.h> #include <Brushes/SlateBorderBrush.h>

View File

@ -1,7 +1,5 @@
// Distributed under the MIT License (MIT) (see accompanying LICENSE file) // Distributed under the MIT License (MIT) (see accompanying LICENSE file)
#include "ImGuiPrivatePCH.h"
#include "SImGuiLayout.h" #include "SImGuiLayout.h"
#include "SImGuiWidget.h" #include "SImGuiWidget.h"

View File

@ -2,6 +2,7 @@
#pragma once #pragma once
#include <UObject/WeakObjectPtr.h>
#include <Widgets/DeclarativeSyntaxSupport.h> #include <Widgets/DeclarativeSyntaxSupport.h>
#include <Widgets/SCompoundWidget.h> #include <Widgets/SCompoundWidget.h>

View File

@ -1,7 +1,5 @@
// Distributed under the MIT License (MIT) (see accompanying LICENSE file) // Distributed under the MIT License (MIT) (see accompanying LICENSE file)
#include "ImGuiPrivatePCH.h"
#include "SImGuiWidget.h" #include "SImGuiWidget.h"
#include "SImGuiCanvasControl.h" #include "SImGuiCanvasControl.h"
@ -15,6 +13,7 @@
#include "TextureManager.h" #include "TextureManager.h"
#include "Utilities/Arrays.h" #include "Utilities/Arrays.h"
#include "Utilities/ScopeGuards.h" #include "Utilities/ScopeGuards.h"
#include "VersionCompatibility.h"
#include <Engine/Console.h> #include <Engine/Console.h>
#include <Engine/GameViewportClient.h> #include <Engine/GameViewportClient.h>

View File

@ -6,6 +6,7 @@
#include "ImGuiModuleSettings.h" #include "ImGuiModuleSettings.h"
#include <Rendering/RenderingCommon.h> #include <Rendering/RenderingCommon.h>
#include <UObject/WeakObjectPtr.h>
#include <Widgets/DeclarativeSyntaxSupport.h> #include <Widgets/DeclarativeSyntaxSupport.h>
#include <Widgets/SCompoundWidget.h> #include <Widgets/SCompoundWidget.h>