build qt source in vs2022 win11

Don't download qt source in tar.xz format, for in Windows, if we unzip it using 7zip, some deep file paths may be truncated, for example, ECMFindModuleHelpersStub.cmake referred by FindEGL.cmake in qtbase\cmake\3rdparty\extra-cmake-modules\find-modules.

This time I download qt-everywhere-src-6.2.2.zip.

In preparation, as to README.md, ActivePerl must be installed, it sucks, we must have an account of it. However, we can find another perl alternative, Strawberry Perl portable edition.

When we build, qt source root path should be short enough like d:\qt.

bld.bat

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
set curpath=%CD%
set vspath=D:\cext\Program Files\Microsoft Visual Studio\2022\Enterprise
set perlpath=D:\work\open\strawberry-perl-5.32.1.1\perl\bin
set clangpath=D:\work\open\libclang
set installpath=D:\cext\Qt
 
call "%vspath%\VC\Auxiliary\Build\vcvars64.bat"
 
set oldpath=%path%
set path=%path%;%perlpath%
 
if not exist %curpath%\bld @mkdir %curpath%\bld
 
cd %curpath%\bld
 
cmake.exe ^
	-G "Ninja" ^
	-DCMAKE_INSTALL_PREFIX:PATH=%curpath%\bld ^
	-DCMAKE_BUILD_TYPE="Debug" ^
	-DFEATURE_clang="ON" ^
	-DCMAKE_PREFIX_PATH="%clangpath%" ^
	-DCMAKE_MAKE_PROGRAM="%vspath%\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" ..
 
cmake --build . --parallel
rem cmake --install . --prefix %installpath%
 
if 0 == 1 (
	rem if we build QtDoc, we must add clang path to system path, otherwise we will get exit code 0xc0000135.
	set path=%path%;%clangpath%\bin
	cmake --build . --target docs
)
 
set path=%oldpath%
cd ..

Modify paths at the beginning of above bld.bat and put the batch file in the qt source root directory, then execute it.

ps1: all in one release of qt is like below url, but we should know all in one is not available since Qt 5.15.
http://download.qt.io/archive/qt/5.9/5.9.2/qt-opensource-linux-x64-5.9.2.run
And we need download online installer for Qt above 5.15 if we don't want to build from scratch:
https://download.qt.io/official_releases/online_installers/

Refer to:
https://ninja-build.org/
https://strawberryperl.com/releases.html
https://github.com/Kitware/CMake/releases/download/v3.22.1/cmake-3.22.1-windows-x86_64.msi

https://download.qt.io/development_releases/prebuilt/libclang/
https://download.qt.io/archive/qt/6.2/6.2.2/single/qt-everywhere-src-6.2.2.zip
https://download.qt.io/official_releases/qtcreator/6.0/6.0.1/qt-creator-opensource-windows-x86_64-6.0.1.exe

https://stackoverflow.com/questions/14807294/how-to-install-cmake-c-compiler-and-cxx-compiler
https://www.cnblogs.com/gearslogy/p/7435202.html