Files
Plugin/Source/ThirdParty/SGFmtThirdPartyLibs/SGFmtThirdPartyLibs.Build.cs
T

171 lines
6.3 KiB
C#
Raw Normal View History

/**
* @file
*
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @section LICENSE
*
* (The MIT License)
*
* Copyright (c) 2020 - 2025 SenseGlove
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* @section DESCRIPTION
*
*
*/
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using UnrealBuildTool;
public class SGFmtThirdPartyLibs : ModuleRules
{
public SGFmtThirdPartyLibs(ReadOnlyTargetRules Target) : base(Target)
{
Type = ModuleType.External;
string ThirdPartyDirectory = Path.GetFullPath(Path.Combine(ModuleDirectory, ".."));
string LibraryPath = Path.GetFullPath(Path.Combine(ThirdPartyDirectory, "lib"));
string LibraryPathAnroidAArch64 = "";
string LibraryPathAnroidX64 = "";
string LibraryName = "fmt";
bool bIsAndroid = Target.IsInPlatformGroup(UnrealPlatformGroup.Android);
bool bIsLinux = Target.Platform == UnrealTargetPlatform.Linux;
bool bIsLinuxArm64 = Target.Platform == UnrealTargetPlatform.LinuxArm64;
bool bIsWin64 = Target.IsInPlatformGroup(UnrealPlatformGroup.Windows) &&
Target.WindowsPlatform.Architecture == UnrealArch.X64;
bool bIsDebugBuild = (Target.Configuration == UnrealTargetConfiguration.Debug);
if (bIsDebugBuild)
{
LibraryName += "d";
}
if (bIsAndroid)
{
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "android"));
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "r25b"));
LibraryPathAnroidAArch64 = Path.GetFullPath(Path.Combine(LibraryPath, "aarch64"));
LibraryPathAnroidX64 = Path.GetFullPath(Path.Combine(LibraryPath, "x86-64"));
LibraryName = string.Format("lib{0}.a", LibraryName);
}
else if (bIsLinux)
{
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "linux"));
#if UE_5_6_OR_LATER
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v25"));
#elif UE_5_5_OR_LATER
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v23"));
#elif UE_5_4_OR_LATER
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v22"));
#else
Debug.Assert(false, "Unsupported engine version or compiler!");
#endif
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "x86-64"));
LibraryName = string.Format("lib{0}.a", LibraryName);
}
else if (bIsLinuxArm64)
{
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "linux"));
#if UE_5_6_OR_LATER
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v25"));
#elif UE_5_5_OR_LATER
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v23"));
#elif UE_5_4_OR_LATER
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v22"));
#else
Debug.Assert(false, "Unsupported engine version or compiler!");
#endif
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "aarch64"));
LibraryName = string.Format("lib{0}.a", LibraryName);
}
else if (bIsWin64)
{
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "windows"));
switch (Target.WindowsPlatform.Compiler)
{
case WindowsCompiler.VisualStudio2022:
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v143"));
break;
default:
Debug.Assert(false, "Unsupported engine version or compiler!");
break;
}
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "x86-64"));
LibraryName = string.Format("{0}.lib", LibraryName);
}
else
{
Debug.Assert(false, "Unsupported platform!");
}
string IncludePath = Path.GetFullPath(Path.Combine(ThirdPartyDirectory, "include"));
PrivateIncludePaths.Add(IncludePath);
if (bIsAndroid)
{
if (bIsDebugBuild)
{
LibraryPathAnroidAArch64 = Path.GetFullPath(Path.Combine(LibraryPathAnroidAArch64, "debug"));
LibraryPathAnroidX64 = Path.GetFullPath(Path.Combine(LibraryPathAnroidX64, "debug"));
}
else
{
LibraryPathAnroidAArch64 = Path.GetFullPath(Path.Combine(LibraryPathAnroidAArch64, "release"));
LibraryPathAnroidX64 = Path.GetFullPath(Path.Combine(LibraryPathAnroidX64, "release"));
}
LibraryPathAnroidAArch64 = Path.GetFullPath(Path.Combine(LibraryPathAnroidAArch64, LibraryName));
LibraryPathAnroidX64 = Path.GetFullPath(Path.Combine(LibraryPathAnroidX64, LibraryName));
PublicAdditionalLibraries.Add(LibraryPathAnroidAArch64);
PublicAdditionalLibraries.Add(LibraryPathAnroidX64);
}
else
{
if (bIsDebugBuild)
{
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "debug"));
}
else
{
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "release"));
}
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, LibraryName));
PublicAdditionalLibraries.Add(LibraryPath);
}
}
}