@@ -2,12 +2,12 @@ set WORKING_DIR=%CD%
22set CONFIG = %1
33set SCRIPT_DIR = %~dp0
44cd %~dp0
5- if /I " %CONFIG% " == " " ( set CONFIG=Release)
5+ if /I " %CONFIG% " == " " set CONFIG = Release
66
7- @ echo " Creating build directory..."
7+ echo " Creating build directory..."
88mkdir build > nul
99
10- @ echo " Generating project files..."
10+ echo " Generating project files..."
1111cd build
1212
1313@ REM Note that we pass the CMAKE_BUILD_TYPE here only to enable the correct
@@ -20,10 +20,15 @@ cd build
2020if /I " %PROCESSOR_ARCHITECTURE% " == " ARM64" (
2121 set " VCPKG_TRIPLET = arm64-windows-static-md"
2222 set " CMAKE_ARCH = ARM64"
23+ set " QT_ARCH_DIR = msvc2022_arm64"
2324) else (
2425 set " VCPKG_TRIPLET = x64-windows-static-md"
2526 set " CMAKE_ARCH = x64"
27+ set " QT_ARCH_DIR = msvc2022_64"
2628)
29+
30+ if " %QT_INSTALL_LOCATION% " == " " call :detect_qt
31+
2732set " VCPKG_ROOT = %SCRIPT_DIR% vcpkg"
2833set " VCPKG_TOOLCHAIN = %VCPKG_ROOT% \scripts\buildsystems\vcpkg.cmake"
2934set " VCPKG_FORCE_SYSTEM_BINARIES = 1"
@@ -41,3 +46,23 @@ if %ERRORLEVEL% neq 0 (
4146)
4247
4348cd %WORKING_DIR%
49+ exit /b 0
50+
51+ :detect_qt
52+ for /f " delims=" %%V in ('dir /b /ad " C:\Qt" 2^ > nul ') do call :try_qt_version " %%V "
53+ if not defined QT_INSTALL_LOCATION goto :detect_qt_missing
54+ echo Auto-detected Qt at %QT_INSTALL_LOCATION%
55+ exit /b 0
56+
57+ :detect_qt_missing
58+ echo WARNING: QT_INSTALL_LOCATION not set and no Qt6 found under C:\Qt
59+ echo CMake configure will fail at find_package(Qt6).
60+ exit /b 0
61+
62+ :try_qt_version
63+ echo %~1 | findstr /r " ^6\." > nul
64+ if errorlevel 1 exit /b 0
65+ if exist " C:\Qt\%~1 \%QT_ARCH_DIR% \lib\cmake\Qt6\Qt6Config.cmake" (
66+ set " QT_INSTALL_LOCATION = C:\Qt\%~1 \%QT_ARCH_DIR% "
67+ )
68+ exit /b 0
0 commit comments