Skip to content

Conversation

@reflectronic
Copy link
Contributor

@reflectronic reflectronic commented Nov 14, 2025

I have tested this and it appears to work well.

Fixes #253

@elad-solomon
Copy link

+1 waiting on this to be merged 🙏

@mamoreau-devolutions
Copy link

+1 waiting on this to be merged as well, we've all started uninstalling Visual Studio 2022 in favor of Visual Studio 2026 at our organization, and it's going to become a pain point very quickly.

@NiceBlueChai
Copy link

Hi — quick question / suggestion: for Visual Studio versions >= 17.0 (VS2022 and later), why not default to the Ninja CMake generator? Visual Studio itself defaults to Ninja for CMake projects, so preferring Ninja when the detected VS version is >= 17.0 would avoid having to update the generator list every time a new VS version is released and would make builds more consistent across developer environments. Could we change the generator selection logic to prefer "Ninja" for VS >= 17.0, and fall back to the current behavior otherwise?

@llc1123
Copy link

llc1123 commented Nov 28, 2025

Hi — quick question / suggestion: for Visual Studio versions >= 17.0 (VS2022 and later), why not default to the Ninja CMake generator? Visual Studio itself defaults to Ninja for CMake projects, so preferring Ninja when the detected VS version is >= 17.0 would avoid having to update the generator list every time a new VS version is released and would make builds more consistent across developer environments. Could we change the generator selection logic to prefer "Ninja" for VS >= 17.0, and fall back to the current behavior otherwise?

I don't think switching the default generator to Ninja will actually solve the issue regarding support for newer Visual Studio versions.

While using Ninja avoids generating .sln files, it does not bypass the need to detect and configure the MSVC toolchain. Here is why switching to Ninja won't fix the underlying detection problem:

  1. Dependency on Toolchain Probing: Even when using the Ninja generator, cmake-rs (and the underlying cc-rs crate) must still "probe" the system to locate the Visual Studio installation. It needs to find the correct paths for cl.exe, link.exe, and the Windows SDKs to set up the necessary environment variables (similar to what vcvarsall.bat does). If the probing logic fails because it doesn't recognize the new VS version/year, it will fail to set up the environment for Ninja just as it fails to generate a VS Solution.
  2. Ninja is not Standard: Unlike MSBuild, Ninja is not available in the system PATH by default on Windows (even if installed via VS Build Tools). Making it the default would break the build for most Windows users unless they are strictly running inside a Developer Command Prompt or have manually added Ninja to their path.

Conclusion:
The root cause is the outdated probing logic for the Visual Studio version, not the choice of generator. Simply switching to Ninja would likely just shift the error from "Generator not found" to "Compiler not found."

Therefore, we should stick to the existing logic and manually update the cmake-rs (and potentially cc-rs) codebase to explicitly support the new Visual Studio version identifiers.

@vron
Copy link

vron commented Dec 10, 2025

In case someone runs in to problems, Im getting the problem mentioned in the comment linked below when using this pullrequest on master, works fine when I apply the same change to latest release though.
b59be3b#commitcomment-172457959

@ChrisDenton
Copy link
Member

I'm not (usually) a cmake-rs maintainer but this looks trivially correct to me so I'll merge it. We'll still need a new cmake-rs release though.

If there's some other improvement that can be made here then please do open an issue to discuss it.

@ChrisDenton ChrisDenton merged commit 6e68d9c into rust-lang:master Dec 10, 2025
28 checks passed
@github-actions github-actions bot mentioned this pull request Dec 10, 2025
ChrisDenton pushed a commit that referenced this pull request Dec 12, 2025
## 🤖 New release

* `cmake`: 0.1.54 -> 0.1.55 (✓ API compatible changes)

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

##
[0.1.55](v0.1.54...v0.1.55)
- 2025-12-11

### Other

- Remove the `\\?\` prefix from paths
([#259](#259))
- Add Visual Studio 2026 support
([#255](#255))
- Make sure that cmake generate build files in current dir
([#194](#194))
- Set the MSRV to 1.65 and test this in CI
- Canonicalize the build directory
- Use `eprintln` instead to print the command running next
([#191](#191))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for Visual Studio 2026 (VS 18)

7 participants