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);
|
||||||
|
|||||||
@@ -47,6 +47,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>
|
||||||
@@ -351,7 +369,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