rules_foreign_cc fails on Windows with msvc_recommended_pragmas.h not found when building cmake targets
rules_foreign_cc version 0.15.0 fails on Windows when building cmake targets (specifically OpenCV) due to an internal pkgconfig tool build failure. The same build works fine on Linux and Mac.
Environment:
OS: Windows Bazel: [your version] rules_foreign_cc: 0.15.0 Bazel config: Using clang-cl via toolchains_llvm, bzlmod enabled
Error:
fatal error C1083: Cannot open include file: 'msvc_recommended_pragmas.h': No such file or directory
The error occurs during an internal pkgconfig tool build using MSVC's nmake.exe and cl.exe, despite the main project being configured to use clang-cl.
Expected behavior:
cmake builds should work on Windows like they do on Linux/Mac, without attempting to build internal tooling with broken MSVC configuration. Workaround attempts:
Configuring Bazel to use clang-cl (successful for main builds, but rules_foreign_cc still uses MSVC for internal tools) Various cmake cache entries to disable pkg-config detection
Related:
This appears to be the same issue as #1359
Minimal reproduction: Simple cmake target with rules_foreign_cc 0.15.0 on Windows triggers the pkgconfig tool build OpenCV