Support Visual Studio 2026 as a generator for CMake dependencies
This commit is contained in:
@@ -241,7 +241,11 @@ namespace Flax.Deploy
|
|||||||
|
|
||||||
if (!File.Exists(solutionFile))
|
if (!File.Exists(solutionFile))
|
||||||
{
|
{
|
||||||
throw new Exception(string.Format("Unable to build solution {0}. Solution file not found.", solutionFile));
|
// CMake VS2026 generator prefers .slnx solution files, just swap the extension for CMake dependencies
|
||||||
|
if (File.Exists(Path.ChangeExtension(solutionFile, "slnx")))
|
||||||
|
solutionFile = Path.ChangeExtension(solutionFile, "slnx");
|
||||||
|
else
|
||||||
|
throw new Exception(string.Format("Unable to build solution {0}. Solution file not found.", solutionFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
string cmdLine = string.Format("\"{0}\" /m /t:Restore,Build /p:Configuration=\"{1}\" /p:Platform=\"{2}\" {3} /nologo", solutionFile, buildConfig, buildPlatform, Verbosity);
|
string cmdLine = string.Format("\"{0}\" /m /t:Restore,Build /p:Configuration=\"{1}\" /p:Platform=\"{2}\" {3} /nologo", solutionFile, buildConfig, buildPlatform, Verbosity);
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ namespace Flax.Deps.Dependencies
|
|||||||
case TargetPlatform.Windows:
|
case TargetPlatform.Windows:
|
||||||
if (architecture == TargetArchitecture.ARM64)
|
if (architecture == TargetArchitecture.ARM64)
|
||||||
{
|
{
|
||||||
// Windows ARM64 doesn't have GPU support, so avoid copying those DLLs around
|
// Windows ARM64 doesn't have precompiled files for GPU support, so avoid copying those DLLs around
|
||||||
ConfigureCmakeSwitch(cmakeSwitches, "PX_COPY_EXTERNAL_DLL", "OFF");
|
ConfigureCmakeSwitch(cmakeSwitches, "PX_COPY_EXTERNAL_DLL", "OFF");
|
||||||
ConfigureCmakeSwitch(cmakeParams, "PX_COPY_EXTERNAL_DLL", "OFF");
|
ConfigureCmakeSwitch(cmakeParams, "PX_COPY_EXTERNAL_DLL", "OFF");
|
||||||
}
|
}
|
||||||
@@ -123,7 +123,7 @@ namespace Flax.Deps.Dependencies
|
|||||||
string bits;
|
string bits;
|
||||||
string arch;
|
string arch;
|
||||||
string binariesSubDir;
|
string binariesSubDir;
|
||||||
string buildPlatform;
|
string buildPlatform = architecture == TargetArchitecture.x86 ? "Win32" : architecture.ToString();
|
||||||
bool suppressBitsPostfix = false;
|
bool suppressBitsPostfix = false;
|
||||||
string binariesPrefix = string.Empty;
|
string binariesPrefix = string.Empty;
|
||||||
var envVars = new Dictionary<string, string>();
|
var envVars = new Dictionary<string, string>();
|
||||||
@@ -147,15 +147,6 @@ namespace Flax.Deps.Dependencies
|
|||||||
break;
|
break;
|
||||||
default: throw new InvalidArchitectureException(architecture);
|
default: throw new InvalidArchitectureException(architecture);
|
||||||
}
|
}
|
||||||
switch (architecture)
|
|
||||||
{
|
|
||||||
case TargetArchitecture.x86:
|
|
||||||
buildPlatform = "Win32";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
buildPlatform = architecture.ToString();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
var msBuildProps = new Dictionary<string, string>();
|
var msBuildProps = new Dictionary<string, string>();
|
||||||
switch (targetPlatform)
|
switch (targetPlatform)
|
||||||
{
|
{
|
||||||
@@ -389,8 +380,17 @@ namespace Flax.Deps.Dependencies
|
|||||||
{
|
{
|
||||||
case TargetPlatform.Windows:
|
case TargetPlatform.Windows:
|
||||||
{
|
{
|
||||||
Build(options, "vc17win64", platform, TargetArchitecture.x64);
|
try
|
||||||
Build(options, "vc17win-arm64", platform, TargetArchitecture.ARM64);
|
{
|
||||||
|
Build(options, "vc18win64", platform, architecture);
|
||||||
|
Build(options, "vc18win-arm64", platform, architecture);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Log.Verbose("Failed to generate VS2026 solution for PhysX, fallback to VS2022");
|
||||||
|
Build(options, "vc17win64", platform, architecture);
|
||||||
|
Build(options, "vc17win-arm64", platform, architecture);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TargetPlatform.Linux:
|
case TargetPlatform.Linux:
|
||||||
|
|||||||
@@ -46,6 +46,24 @@ namespace Flax.Deps
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected static TargetPlatform BuildPlatform => Platform.BuildPlatform.Target;
|
protected static TargetPlatform BuildPlatform => Platform.BuildPlatform.Target;
|
||||||
|
|
||||||
|
|
||||||
|
private static Version? _cmakeVersion;
|
||||||
|
protected static Version CMakeVersion
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_cmakeVersion == null)
|
||||||
|
{
|
||||||
|
var versionOutput = Utilities.ReadProcessOutput("cmake", "--version");
|
||||||
|
var versionStart = versionOutput.IndexOf("cmake version ") + "cmake version ".Length;
|
||||||
|
var versionEnd = versionOutput.IndexOfAny(['-', '\n', '\r'], versionStart); // End of line or dash before Git hash
|
||||||
|
var versionString = versionOutput.Substring(versionStart, versionEnd - versionStart);
|
||||||
|
_cmakeVersion = new Version(versionString);
|
||||||
|
}
|
||||||
|
return _cmakeVersion;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the platforms list supported by this dependency to build on the current build platform (based on <see cref="Platform.BuildPlatform"/>).
|
/// Gets the platforms list supported by this dependency to build on the current build platform (based on <see cref="Platform.BuildPlatform"/>).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -335,7 +353,13 @@ namespace Flax.Deps
|
|||||||
break;
|
break;
|
||||||
default: throw new InvalidArchitectureException(architecture);
|
default: throw new InvalidArchitectureException(architecture);
|
||||||
}
|
}
|
||||||
cmdLine = string.Format("CMakeLists.txt -G \"Visual Studio 17 2022\" -A {0}", arch);
|
if (CMakeVersion.Major > 4 || (CMakeVersion.Major == 4 && CMakeVersion.Minor >= 2))
|
||||||
|
{
|
||||||
|
// This generates both .sln and .slnx solution files
|
||||||
|
cmdLine = string.Format("CMakeLists.txt -G \"Visual Studio 17 2022\" -G \"Visual Studio 18 2026\" -A {0}", arch);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
cmdLine = string.Format("CMakeLists.txt -G \"Visual Studio 17 2022\" -A {0}", arch);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TargetPlatform.PS4:
|
case TargetPlatform.PS4:
|
||||||
|
|||||||
Reference in New Issue
Block a user