rust-lang / cmake-rs

Rust build dependency for running cmake
https://docs.rs/cmake
Apache License 2.0
310 stars 123 forks source link

Windows 2022: couldn't determine visual studio generator #141

Open nibanks opened 2 years ago

nibanks commented 2 years ago

We use the cmake crate in our CI for building msquic. We just tried updating the Azure Pipeline to use Windows Server 2022 instead of 2019 to build it and the CI failed.

We are getting the following error (from here):

  --- stderr
  thread 'main' panicked at '

  couldn't determine visual studio generator
  if VisualStudio is installed, however, consider running the appropriate vcvars script before building this crate

We have no problem with any non-Rust cmake builds, so I suspect this is something specific to the the cmake crate. Do you know of any work around for this? For the time being we can continue to use 2019, but eventually that will be deprecated. Thanks!

aloucks commented 2 years ago

Looks like the error is coming from the cc crate: https://github.com/alexcrichton/cc-rs/blob/030baede12f079793cc50d6f90b677b889c49fcd/src/windows_registry.rs#L150

Byron commented 2 years ago

Thanks, this helped me to fix the same issue by settings runs-on: windows-2019 for the time being.

stefangalowicz commented 2 years ago

@aloucks Looks to me like it's not cc but cmake: https://github.com/alexcrichton/cmake-rs/blob/7793895d88acc45d29fac7c711ddaef11c897ea9/src/lib.rs#L610-L621

I assume Vs17 must be added.

@nibanks Is your target i686?

nibanks commented 2 years ago

@nibanks Is your target i686?

We're just running on a windows-2022 agent in Azure Pipelines. I assume it's x64. cc @thhous-msft

pacmancoder commented 2 years ago

Hi, for anyone interested in a temporary solution - just add this patch to your root Cargo.toml, VS2022 support is already merged, but new cc version is not yet released:

[patch.crates-io]
cc = { git = "https://github.com/alexcrichton/cc-rs" }