From cd22b704e02e80e9299f9a767960c8b94a6b261e Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Tue, 11 Aug 2026 09:26:23 -0400 Subject: [PATCH] build(windows): default to qt6-static --- .github/workflows/ci-windows.yml | 4 +--- CMakeLists.txt | 1 + cmake/prep/options.cmake | 2 +- cmake/prep/static_qt.cmake | 34 ++++++++++++++++++++++++++++++++ docs/building.md | 12 +++++------ 5 files changed, 43 insertions(+), 10 deletions(-) create mode 100644 cmake/prep/static_qt.cmake diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml index 7544807d6f4..941fd6b0b19 100644 --- a/.github/workflows/ci-windows.yml +++ b/.github/workflows/ci-windows.yml @@ -240,12 +240,10 @@ jobs: -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::" diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ad1ef27327..f6019b50180 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,7 @@ include(${CMAKE_MODULE_PATH}/prep/build_version.cmake) # 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) diff --git a/cmake/prep/options.cmake b/cmake/prep/options.cmake index ac20de4a644..4b2455bf295 100644 --- a/cmake/prep/options.cmake +++ b/cmake/prep/options.cmake @@ -20,7 +20,7 @@ option(SUNSHINE_ENABLE_TRAY "Enable system tray icon." ON) 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) diff --git a/cmake/prep/static_qt.cmake b/cmake/prep/static_qt.cmake new file mode 100644 index 00000000000..9a2c61396ae --- /dev/null +++ b/cmake/prep/static_qt.cmake @@ -0,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() diff --git a/docs/building.md b/docs/building.md index b9b551d2a52..5420906553d 100644 --- a/docs/building.md +++ b/docs/building.md @@ -189,13 +189,13 @@ fi 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).