ref:cf52f4b6f33cc9d143f0f6bb67c9891fe3563e54

build(windows): default to qt6-static (#5497)

SHA: cf52f4b6f33cc9d143f0f6bb67c9891fe3563e54
Author: Dave Lane <42013603+ReenigneArcher@users.noreply.github.com>
Date: 2026-08-11 15:56
Parents: 3cba9ba
5 files changed +43 -10
Type
.github/workflows/ci-windows.yml +1 −3
@@ -240,12 +240,10 @@
-S . \
-DBUILD_WERROR=ON \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_PREFIX_PATH="${MINGW_PREFIX}/qt6-static" \
-DSUNSHINE_ASSETS_DIR=assets \
-DSUNSHINE_PUBLISHER_NAME="${GITHUB_REPOSITORY_OWNER}" \
-DSUNSHINE_PUBLISHER_WEBSITE="https://app.lizardbyte.dev" \
-DSUNSHINE_PUBLISHER_ISSUE_URL="https://app.lizardbyte.dev/support" \
-DSUNSHINE_USE_STATIC_QT=ON
-DSUNSHINE_PUBLISHER_ISSUE_URL="https://app.lizardbyte.dev/support"
echo "::add-matcher::.github/matchers/gcc.json"
ninja -C build
echo "::remove-matcher owner=gcc::"
cmake/prep/options.cmake +1 −1
@@ -20,7 +20,7 @@
if(WIN32)
option(SUNSHINE_USE_STATIC_QT
"Require static Qt libraries and their static third-party dependencies." OFF)
"Require static Qt libraries and their static third-party dependencies." ON)
endif()
option(SUNSHINE_SYSTEM_VULKAN_HEADERS "Use system installation of vulkan-headers rather than the submodule." OFF)
cmake/prep/static_qt.cmake +34 −0
@@ -1,0 +1,34 @@
# Configure the standard MSYS2 static Qt prefix automatically for Windows builds.
if(WIN32 AND SUNSHINE_ENABLE_TRAY AND SUNSHINE_USE_STATIC_QT AND NOT Qt6_DIR)
set(_sunshine_static_qt_prefix "")
# Prefer the prefix exported by an interactive MSYS2 environment.
if(DEFINED ENV{MINGW_PREFIX} AND NOT "$ENV{MINGW_PREFIX}" STREQUAL "") # cmake-lint: disable=W0106
file(TO_CMAKE_PATH "$ENV{MINGW_PREFIX}/qt6-static" _sunshine_static_qt_candidate)
if(EXISTS "${_sunshine_static_qt_candidate}/lib/cmake/Qt6/Qt6Config.cmake")
set(_sunshine_static_qt_prefix "${_sunshine_static_qt_candidate}")
endif()
endif()
# IDEs may not inherit MINGW_PREFIX, so derive the toolchain root from the compiler path.
if(NOT _sunshine_static_qt_prefix)
get_filename_component(_sunshine_compiler_bin_dir "${CMAKE_CXX_COMPILER}" DIRECTORY)
get_filename_component(_sunshine_compiler_prefix "${_sunshine_compiler_bin_dir}" DIRECTORY)
set(_sunshine_static_qt_candidate "${_sunshine_compiler_prefix}/qt6-static")
if(EXISTS "${_sunshine_static_qt_candidate}/lib/cmake/Qt6/Qt6Config.cmake")
set(_sunshine_static_qt_prefix "${_sunshine_static_qt_candidate}")
endif()
endif()
if(_sunshine_static_qt_prefix)
list(APPEND CMAKE_PREFIX_PATH "${_sunshine_static_qt_prefix}")
list(REMOVE_DUPLICATES CMAKE_PREFIX_PATH)
message(STATUS "Using static Qt prefix: ${_sunshine_static_qt_prefix}")
endif()
unset(_sunshine_compiler_bin_dir)
unset(_sunshine_compiler_prefix)
unset(_sunshine_static_qt_candidate)
unset(_sunshine_static_qt_prefix)
endif()
CMakeLists.txt +1 −0
@@ -50,6 +50,7 @@
# cmake build flags
include(${CMAKE_MODULE_PATH}/prep/options.cmake)
include(${CMAKE_MODULE_PATH}/prep/static_qt.cmake)
# initial prep
include(${CMAKE_MODULE_PATH}/prep/init.cmake)
docs/building.md +6 −6
@@ -189,12 +189,12 @@
pacman -S "${dependencies[@]}"
```
The static Qt package is installed under a separate prefix. Add the following options when configuring a Windows
build so Sunshine and Qt's third-party dependencies are linked statically:
Static Qt is enabled by default on Windows. Sunshine automatically adds the MSYS2 static Qt prefix at
`${MINGW_PREFIX}/qt6-static` when that package is installed. If an IDE does not inherit `MINGW_PREFIX`, Sunshine
derives the same prefix from the selected compiler. If static Qt is installed in a custom location, specify it with
`-DCMAKE_PREFIX_PATH=/path/to/qt6-static`.
```bash
-DCMAKE_PREFIX_PATH="${MINGW_PREFIX}/qt6-static" \
-DSUNSHINE_USE_STATIC_QT=ON
```
To use dynamic Qt instead, configure with `-DSUNSHINE_USE_STATIC_QT=OFF` and ensure the dynamic Qt package is
available through the normal toolchain prefix.
To create a WiX installer, you also need to install [.NET](https://dotnet.microsoft.com/download).