Skip to content

Commit 42d0fef

Browse files
committed
MSBuild: Don't hardcode Qt versions in MSBuild
1 parent e49378b commit 42d0fef

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/myMCpp.vcxproj

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,13 @@
179179
<Command>
180180
if not exist "$(TargetDir)translations" mkdir "$(TargetDir)translations"
181181

182-
set "QT_BIN=C:\Qt\6.10.2\msvc2022_64\bin"
182+
set "QT_BIN=$(QtToolsPath)"
183+
if not exist "%QT_BIN%\qmake.exe" if defined QTDIR set "QT_BIN=%QTDIR%\bin"
184+
185+
if not exist "%QT_BIN%\lrelease.exe" (
186+
echo Qt lrelease not found at "%QT_BIN%". Skipping translation generation.
187+
goto :after_lrelease
188+
)
183189

184190
"%QT_BIN%\lrelease.exe" "$(ProjectDir)ui\Translations\myMCpp_af-ZA.ts" -qm "$(TargetDir)translations\myMCpp_af-ZA.qm"
185191
"%QT_BIN%\lrelease.exe" "$(ProjectDir)ui\Translations\myMCpp_ar-SA.ts" -qm "$(TargetDir)translations\myMCpp_ar-SA.qm"
@@ -214,7 +220,14 @@ set "QT_BIN=C:\Qt\6.10.2\msvc2022_64\bin"
214220
"%QT_BIN%\lrelease.exe" "$(ProjectDir)ui\Translations\myMCpp_zh-CN.ts" -qm "$(TargetDir)translations\myMCpp_zh-CN.qm"
215221
"%QT_BIN%\lrelease.exe" "$(ProjectDir)ui\Translations\myMCpp_zh-TW.ts" -qm "$(TargetDir)translations\myMCpp_zh-TW.qm"
216222

223+
:after_lrelease
217224
xcopy /Y /E /I "$(ProjectDir)..\resources" "$(TargetDir)resources"
225+
226+
if exist "%QT_BIN%\windeployqt.exe" (
227+
"%QT_BIN%\windeployqt.exe" --no-compiler-runtime "$(TargetPath)"
228+
) else (
229+
echo Qt windeployqt not found at "%QT_BIN%". Qt DLLs/plugins will not be deployed.
230+
)
218231
</Command>
219232
<Message>Generating translations and copying resources to output...</Message>
220233
</PostBuildEvent>

0 commit comments

Comments
 (0)