diff --git a/Source/Tools/Flax.Build/Deploy/VCEnvironment.cs b/Source/Tools/Flax.Build/Deploy/VCEnvironment.cs index cfcbf9866..afe5c8e3c 100644 --- a/Source/Tools/Flax.Build/Deploy/VCEnvironment.cs +++ b/Source/Tools/Flax.Build/Deploy/VCEnvironment.cs @@ -241,7 +241,11 @@ namespace Flax.Deploy 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); diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs b/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs index 32e2d2f38..c8c85363a 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/PhysX.cs @@ -94,7 +94,7 @@ namespace Flax.Deps.Dependencies case TargetPlatform.Windows: 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(cmakeParams, "PX_COPY_EXTERNAL_DLL", "OFF"); } @@ -122,7 +122,7 @@ namespace Flax.Deps.Dependencies string bits; string arch; string binariesSubDir; - string buildPlatform; + string buildPlatform = architecture == TargetArchitecture.x86 ? "Win32" : architecture.ToString(); bool suppressBitsPostfix = false; string binariesPrefix = string.Empty; var envVars = new Dictionary(); @@ -146,15 +146,6 @@ namespace Flax.Deps.Dependencies break; default: throw new InvalidArchitectureException(architecture); } - switch (architecture) - { - case TargetArchitecture.x86: - buildPlatform = "Win32"; - break; - default: - buildPlatform = architecture.ToString(); - break; - } var msBuildProps = new Dictionary(); switch (targetPlatform) { @@ -388,8 +379,17 @@ namespace Flax.Deps.Dependencies { case TargetPlatform.Windows: { - Build(options, "vc17win64", platform, TargetArchitecture.x64); - Build(options, "vc17win-arm64", platform, TargetArchitecture.ARM64); + try + { + 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; } case TargetPlatform.Linux: diff --git a/Source/Tools/Flax.Build/Deps/Dependency.cs b/Source/Tools/Flax.Build/Deps/Dependency.cs index 479911943..26803eb06 100644 --- a/Source/Tools/Flax.Build/Deps/Dependency.cs +++ b/Source/Tools/Flax.Build/Deps/Dependency.cs @@ -47,6 +47,24 @@ namespace Flax.Deps /// 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; + } + } + /// /// Gets the platforms list supported by this dependency to build on the current build platform (based on ). /// @@ -351,7 +369,13 @@ namespace Flax.Deps break; 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; } case TargetPlatform.PS4: