Skip to content

Commit 9fad78e

Browse files
Merge pull request #1224 from npinto97/ci/fix-windows-msvc-path
ci: fix Windows MSVC path resolution and Qt configuration
2 parents a8bab92 + ab72342 commit 9fad78e

2 files changed

Lines changed: 25 additions & 3 deletions

File tree

.github/workflows/build-windows.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,34 @@ jobs:
7272
run: |
7373
mkdir deps
7474
mkdir deps/vcruntime
75-
# Copy from VS 2022 Enterprise installation on runner
76-
$vsRedist = Get-ChildItem "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Redist\MSVC\*\x64\Microsoft.VC143.CRT" | Select-Object -First 1
75+
# Dynamically locate VS installation on runner
76+
$vsPath = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -property installationPath
77+
if (-not $vsPath) {
78+
$vsPath = (Get-ChildItem "C:\Program Files\Microsoft Visual Studio\*\*" | Where-Object { Test-Path "$_\VC\Redist\MSVC" } | Select-Object -First 1).FullName
79+
}
80+
$vsRedist = Get-ChildItem "$vsPath\VC\Redist\MSVC\*\${{ matrix.vc_redist_arch }}\Microsoft.VC*.CRT" | Select-Object -First 1
81+
if (-not $vsRedist) {
82+
$vsRedist = Get-ChildItem "$vsPath\VC\Redist\MSVC" -Recurse -Filter "Microsoft.VC*.CRT" | Where-Object { $_.FullName -like "*${{ matrix.vc_redist_arch }}*" } | Select-Object -First 1
83+
}
7784
Copy-Item "$vsRedist\*.dll" deps/vcruntime/
7885
# Also grab VCRedist installer for optional system-wide install
7986
Invoke-WebRequest -Uri "https://aka.ms/vs/17/release/vc_redist.x64.exe" -OutFile deps/vc_redist.x64.exe
8087
shell: powershell
8188
- name: Build
8289
run: |
83-
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\${{ matrix.vcvars }}"
90+
set "VS_PATH="
91+
for /f "tokens=*" %%i in ('"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -property installationPath 2^>nul') do set "VS_PATH=%%i"
92+
if not defined VS_PATH (
93+
for /d %%d in ("C:\Program Files\Microsoft Visual Studio\*") do (
94+
for /d %%e in ("%%d\*") do (
95+
if exist "%%e\VC\Auxiliary\Build\${{ matrix.vcvars }}" set "VS_PATH=%%e"
96+
)
97+
)
98+
)
99+
call "%VS_PATH%\VC\Auxiliary\Build\${{ matrix.vcvars }}"
84100
cd build
85101
set PATH=%PATH%;C:\Program Files (x86)\Inno Setup 6;%CD%
102+
set "QT_ROOT_DIR=%QT_ROOT_DIR:\=/%"
86103
cmake -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=output -DQTROOT=%QT_ROOT_DIR% -DMPV_INCLUDE_DIR=mpv/include -DMPV_LIBRARY=mpv/libmpv-2.dll -DCHECK_FOR_UPDATES=ON -DUSE_STATIC_MPVQT=ON ..
87104
lib /def:mpv\mpv.def /out:mpv\libmpv-2.dll.lib /MACHINE:${{ matrix.machine }}
88105
ninja

CMakeModules/QtConfiguration.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ if("${QTROOT}" STREQUAL "")
1717
endforeach()
1818
endif()
1919

20+
if(NOT "${QTROOT}" STREQUAL "")
21+
file(TO_CMAKE_PATH "${QTROOT}" QTROOT)
22+
set(QTROOT "${QTROOT}" CACHE PATH "Qt root directory" FORCE)
23+
endif()
24+
2025
if((NOT IS_DIRECTORY ${QTROOT}) AND (NOT "${QTROOT}" STREQUAL ""))
2126
# Write qt.conf in the Qt depends directory so that the Qt tools can find QML files
2227
set(QTCONFCONTENT "[Paths]

0 commit comments

Comments
 (0)