Skip to content

Instantly share code, notes, and snippets.

@cristianadam
Created June 15, 2022 22:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cristianadam/ea1eb5a4d8a763887fecaaf60b96d1d8 to your computer and use it in GitHub Desktop.
Save cristianadam/ea1eb5a4d8a763887fecaaf60b96d1d8 to your computer and use it in GitHub Desktop.
Script used to compile Qt 6.3.0 statically for Windows Arm64. First run cmake -P qt-6.3.0-win-msvc.cmake in a x86_64 console, then in a arm64 one.
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
# Run this script on a Windows host to generate Qt binaries.
# Set the PATH environment variable to contain the locations of cmake and git.
if ("$ENV{VSCMD_ARG_TGT_ARCH}" STREQUAL "x64")
set(arch "x86_64")
elseif ("$ENV{VSCMD_ARG_TGT_ARCH}" STREQUAL "x86")
set(arch "i386")
elseif ("$ENV{VSCMD_ARG_TGT_ARCH}" STREQUAL "arm64")
set(arch "arm64")
else()
message("VSCMD_ARG_TGT_ARCH env var not recognized. Run this from a Visual Studio Command Prompt.")
return()
endif()
if (NOT "x$ENV{VCToolsVersion}" STREQUAL "x")
set(toolset "msvc_v$ENV{VCToolsVersion}")
else()
message( "VCToolsVersion env var not set. Run this from a Visual Studio Command Prompt.")
return()
endif()
set(srcname "qt-everywhere-src-6.3.0")
set(pkgname "qt-6.3.0-win-${arch}-${toolset}")
set(pkgname_host "qt-6.3.0-win-x86_64-${toolset}")
set(topdir "${CMAKE_CURRENT_LIST_DIR}")
set(srcdir "${topdir}/${srcname}")
set(blddir "${topdir}/${pkgname}-build")
set(prefix "${topdir}/${pkgname}")
set(prefix_host "${topdir}/${pkgname_host}")
# Qt Source
if (NOT EXISTS "${srcdir}")
file(DOWNLOAD "https://download.qt.io/official_releases/qt/6.3/6.3.0/single/qt-everywhere-src-6.3.0.tar.xz" qt.tar.xz
EXPECTED_HASH SHA256=cd2789cade3e865690f3c18df58ffbff8af74cc5f01faae50634c12eb52dd85b)
file(ARCHIVE_EXTRACT INPUT qt.tar.xz)
file(REMOVE qt.tar.xz)
endif()
# Download and use LLVM's clang-cl to compiler for arm64
if (${arch} STREQUAL "arm64" AND CMAKE_ARGV3 STREQUAL "clang-cl")
set(ENV{PATH} "c:/Program Files/LLVM/bin;$ENV{PATH}")
set(ENV{CC} "clang-cl --target=arm64-pc-windows-msvc")
set(ENV{CXX} "clang-cl --target=arm64-pc-windows-msvc")
endif()
# Build Qt
if (NOT EXISTS "${blddir}")
file(MAKE_DIRECTORY "${blddir}")
if ("${arch}" STREQUAL "arm64")
set(qt_platform "win32-arm64-msvc")
set(qt_host_path -qt-host-path "${prefix_host}")
else()
set(qt_platform "win32-msvc")
unset(qt_host_path)
endif()
execute_process(
WORKING_DIRECTORY "${blddir}"
COMMAND
${srcdir}/configure.bat
-prefix ${prefix}
-static
-static-runtime
-release
-opensource -confirm-license
-platform ${qt_platform}
${qt_host_path}
-gui
-widgets
-qt-doubleconversion
-qt-freetype
-qt-harfbuzz
-qt-pcre
-qt-zlib
-qt-libpng
-qt-libjpeg
-no-gif
-no-tiff
-no-webp
-no-icu
-no-pch
-no-opengl
-no-dbus
-no-accessibility
-no-feature-androiddeployqt
-no-feature-assistant
-no-feature-designer
-no-feature-linguist
-no-feature-pixeltool
-no-feature-printsupport
-no-feature-qtattributionsscanner
-no-feature-qtdiag
-no-feature-qtplugininfo
-no-feature-sql
-no-feature-windeployqt
-skip qtconnectivity
-skip qtdeclarative
-skip qtdoc
-skip qtlottie
-skip qtmqtt
-skip qtmultimedia
-skip qtopcua
-skip qtquick3d
-skip qtquicktimeline
-skip qtscxml
-skip qtsensors
-skip qtserialport
-skip qtsvg
-skip qtvirtualkeyboard
-skip qtwayland
-skip qtwebchannel
-skip qtwebengine
-skip qtwebsockets
-skip qtwebview
-nomake examples
-nomake tests
)
execute_process(
WORKING_DIRECTORY "${blddir}"
COMMAND ninja
)
endif()
# Install Qt
if (NOT EXISTS "${prefix}")
execute_process(
WORKING_DIRECTORY "${blddir}"
COMMAND ninja install
)
endif()
# Package Qt
file(ARCHIVE_CREATE OUTPUT "${pkgname}.zip" PATHS "${pkgname}" FORMAT "zip")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment