Skip to content

windows: build with Visual Studio 2026 / newer MSVC toolsets#4328

Open
exzile wants to merge 2 commits into
openvinotoolkit:mainfrom
exzile:windows-vs-autodetect
Open

windows: build with Visual Studio 2026 / newer MSVC toolsets#4328
exzile wants to merge 2 commits into
openvinotoolkit:mainfrom
exzile:windows-vs-autodetect

Conversation

@exzile

@exzile exzile commented Jun 26, 2026

Copy link
Copy Markdown

Fixes #4333.

The Windows build scripts hardcode Visual Studio 2022 Build Tools and a specific MSVC toolset version, so a machine with only Visual Studio 2026 (v18) cannot build OVMS. This PR detects the installed Visual Studio and toolset, and fixes a couple of newer-toolchain breakages it surfaced.

Changes

1. Auto-detect Visual Studio via vswhere (windows_install_build_dependencies.bat, windows_build.bat, windows_setupvars.bat, windows_test.bat)

  • Replaces the hardcoded C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools with vswhere -latest -requires ...VC.Tools.x86.x64 -property installationPath (works with BuildTools/Community/Pro/Enterprise).
  • Derives the CMake generator (Visual Studio <major> <year>) from the detected major version instead of the literal "Visual Studio 17 2022".
  • Auto-detects the installed MSVC toolset version instead of the pinned 14.44.35207.

2. Allow newer MSVC toolsets to compile XLA (.bazelrc)

  • MSVC 14.51+ (VS 2026) raises C5285 ("specializing std::is_signed is forbidden") on TensorFlow/XLA's quantized-type specializations (xla/tsl/framework/type_traits.h). XLA builds with /WX, so it becomes a fatal C2220. Added build:windows --copt=/wd5285 (+ --host_copt) to suppress this benign upstream warning. Without it, only the older 14.44 toolset builds.

3. OpenCV generator default toolset / CMake 4.x (windows_install_build_dependencies.bat)

  • Dropped the hardcoded -T v142 (VS 2019 toolset, absent on a VS 2026 box); cmake uses the generator's default (installed) toolset.
  • Pass -D PYTHON3_EXECUTABLE and disable the OpenCV python bindings — newer CMake (4.x) errors in OpenCV's python auto-detection (find_package called with invalid argument "OFF"); OVMS only needs the C++ libs.

4. Non-privileged GenAI link (windows_install_build_dependencies.bat)

  • mklink /dmklink /j for the openvino link. A directory junction is functionally equivalent here and does not require SeCreateSymbolicLinkPrivilege (admin / Developer Mode), so the dependency install works in a non-elevated shell.

Testing

  • Built ovms.exe end-to-end on Visual Studio 2026 (18.7, MSVC 14.51) with windows_install_build_dependencies.bat + windows_build.bat opt --with_python — produces a working server (OpenVINO Model Server 2026.3.0).
  • Not re-tested on VS 2022 (no VS2022 box available); the vswhere/generator/toolset detection resolves the 2022 values by the same logic, and the /wd5285 + OpenCV changes are no-ops on the older toolset.

Notes

  • CMake must be on PATH (the VS "C++ CMake tools" component or a standalone install).

exzile and others added 2 commits June 26, 2026 14:08
- Auto-detect Visual Studio via vswhere instead of hardcoding VS 2022
  BuildTools, the "Visual Studio 17 2022" CMake generator, and the
  14.44.35207 toolset (windows_install_build_dependencies.bat,
  windows_build.bat, windows_setupvars.bat, windows_test.bat).
- .bazelrc: suppress MSVC C5285 (/wd5285) so newer toolsets (14.51+,
  VS 2026) can compile XLA's std::is_signed specializations, which XLA
  builds with /WX.
- OpenCV: drop hardcoded -T v142 (use the generator default toolset) and
  pass PYTHON3_EXECUTABLE / disable the python bindings to avoid a
  CMake 4.x python-detection error.
- Use mklink /j (junction) instead of /d (symlink) for the openvino link
  so the dependency install works without admin / Developer Mode.

Tested end-to-end on Visual Studio 2026 (MSVC 14.51).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.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.

Windows build fails on Visual Studio 2026 / newer MSVC toolsets (hardcoded VS2022 + toolset)

1 participant