Skip to content

Instantly share code, notes, and snippets.

@PreyK
Created March 5, 2019 10:27
Show Gist options
  • Save PreyK/b56f310b225f2308398706b158913b45 to your computer and use it in GitHub Desktop.
Save PreyK/b56f310b225f2308398706b158913b45 to your computer and use it in GitHub Desktop.
Modified build script of https://github.com/Brandon-Wilson/OpenCV-Plugin to work un newer unreal versions
// Some copyright should be here...
//modified to work with unreal 4.21
using UnrealBuildTool;
using System.IO;
public class OpenCV : ModuleRules
{
private string ThirdPartyPath
{
get { return Path.GetFullPath(Path.Combine(ModuleDirectory, "../../../../ThirdParty/")); }
}
public OpenCV(ReadOnlyTargetRules Target) : base(Target)
{
// Startard Module Dependencies
PublicDependencyModuleNames.AddRange(new string[] { "Core", "RHI", "RenderCore" });
PrivateDependencyModuleNames.AddRange(new string[] { "CoreUObject", "Engine", "Slate", "SlateCore" });
// Start OpenCV linking here!
bool isLibrarySupported = false;
// Create OpenCV Path
string OpenCVPath = Path.Combine(ThirdPartyPath, "OpenCV");
// Get Library Path
string LibPath = "";
bool isdebug = Target.Configuration == UnrealTargetConfiguration.Debug && Target.bDebugBuildsActuallyUseDebugCRT; // changed
if (Target.Platform == UnrealTargetPlatform.Win64)
{
LibPath = Path.Combine(OpenCVPath, "Libraries", "Win64");
isLibrarySupported = true;
}
else if (Target.Platform == UnrealTargetPlatform.Win32)
{
// TODO: add OpenCV binaries for Win32
}
else if (Target.Platform == UnrealTargetPlatform.Mac)
{
// TODO: add OpenCV binaries for Mac
}
else if (Target.Platform == UnrealTargetPlatform.Linux)
{
// TODO: add OpenCV binaries for Linux
}
else
{
string Err = string.Format("{0} dedicated server is made to depend on {1}. We want to avoid this, please correct module dependencies.", Target.Platform.ToString(), this.ToString()); System.Console.WriteLine(Err);
}
if (isLibrarySupported)
{
//Add Include path
PublicIncludePaths.AddRange(new string[] { Path.Combine(OpenCVPath, "Includes") });
// Add Library Path
PublicLibraryPaths.Add(LibPath);
//Add Static Libraries
PublicAdditionalLibraries.Add("opencv_world320.lib");
//Add Dynamic Libraries
PublicDelayLoadDLLs.Add("opencv_world320.dll");
PublicDelayLoadDLLs.Add("opencv_ffmpeg320_64.dll");
}
PublicDefinitions.Add(string.Format("WITH_OPENCV_BINDING={0}", isLibrarySupported ? 1 : 0));
}
}
@austinbhale
Copy link

Thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment