Download

Include header files without full path

Hello,
I am using d3d11 libraries and PrivateIncludePaths seems not to work in the Build.cs because when I call #include for those headers I have to write full paths.


#include "Runtime/Windows/D3D11RHI/Private/Windows/D3D11RHIBasePrivate.h"
#include "Runtime/Windows/D3D11RHI/Private/D3D11StateCachePrivate.h"

Here is what i want :


#include "D3D11RHIBasePrivate.h"
#include "D3D11StateCachePrivate.h"

Build.cs



public class CustomPlugin : ModuleRules
{ public CustomPlugin(ReadOnlyTargetRules Target) : base(Target)
{
  [INDENT=2]PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
string engine_path = Path.GetFullPath(Target.RelativeEnginePath);
PrivateIncludePaths.AddRange([/INDENT]
  [INDENT=3]new string] {[/INDENT]
  [INDENT=4]engine_path+"Runtime/Windows/D3D11RHI/Private/",
engine_path+"Runtime/Windows/D3D11RHI/Private/Windows/",
"CustomPlugin/Private"[/INDENT]
  [INDENT=3]}[/INDENT]
  [INDENT=2]);


PublicIncludePaths.AddRange([/INDENT]
  [INDENT=3]new string]
{[/INDENT]
  [INDENT=4]engine_path+"Source/Runtime/Windows/D3D11RHI/Public/"[/INDENT]
  [INDENT=3]}[/INDENT]
  [INDENT=2]);

PublicAdditionalLibraries.Add("dxgi.lib");


PrivateDependencyModuleNames.AddRange([/INDENT]
  [INDENT=3]new string]
{[/INDENT]
  [INDENT=4]"Core",
"CoreUObject",
"Engine",
"Renderer",
"RenderCore",
"RHI",
"Projects",
"D3D11RHI"

// ... add private dependencies that you statically link with here ...[/INDENT]
  [INDENT=3]}[/INDENT]
  [INDENT=2]);[/INDENT]
  

}
 
 }



What I did wrong ?

I solved this problem replacing engine_path+“Source/Runtime/Windows/D3D11RHI/Public/” by “…/…/…/…/…/Epic Games/UE_4.24/Engine/Source/Runtime/Windows/D3D11RHI/Private/”.

But now i Included D3D11RHIPrivate.h and got
Error C4668 ‘NV_AFTERMATH’ is not defined as a preprocessor macro, replacing with ‘0’ for ‘#if/#elif’ SceneTest D:\RTR\UNREAL\Epic Games\UE_4.24\Engine\Source\Runtime\Windows\D3D11RHI\Private\D3D11RHIPrivate.h 37.
Error C4668 ‘INTEL_METRICSDISCOVERY’ is not defined as a preprocessor macro, replacing with ‘0’ for ‘#if/#elif’ SceneTest D:\RTR\UNREAL\Epic Games\UE_4.24\Engine\Source\Runtime\Windows\D3D11RHI\Private\D3D11RHIPrivate.h 44.

@chomusuke2521
You need .build.cs like below one to use D3D11RHI properly:


// Some copyright should be here...

using System.IO;
using System.Collections.Generic;
using Tools.DotNETCommon;

namespace UnrealBuildTool.Rules
{
public class TestGPUReadback : ModuleRules
{
public TestGPUReadback(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;

PublicIncludePaths.AddRange(
new string] {
// ... add public include paths required here ...
}
);

PublicDependencyModuleNames.AddRange(
new string]
{
"Core",
// ... add other public dependencies that you statically link with here ...
}
);


PrivateDependencyModuleNames.AddRange(
new string]
{
"CoreUObject",
"Engine",
"Slate",
"SlateCore",
"RHI",
"RenderCore",
"D3D11RHI"
// ... add private dependencies that you statically link with here ...
}
);

var EngineDir = Path.GetFullPath(Target.RelativeEnginePath);

PrivateIncludePaths.AddRange(new string]
{
Path.Combine(EngineDir, "Source/Runtime/Windows/D3D11RHI/Private"),
Path.Combine(EngineDir, "Source/Runtime/Windows/D3D11RHI/Private/Windows"),
});

// required by D3D11RHI
AddEngineThirdPartyPrivateStaticDependencies(Target, "IntelMetricsDiscovery");
AddEngineThirdPartyPrivateStaticDependencies(Target, "IntelExtensionsFramework");
AddEngineThirdPartyPrivateStaticDependencies(Target, "NVAftermath");

DynamicallyLoadedModuleNames.AddRange(
new string]
{
// ... add any modules that your module loads dynamically here ...
}
);
}
}
}