From fd3211fae313068d850f2c13953af201eb15662e Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Wed, 1 Apr 2026 09:14:23 +0300 Subject: [PATCH] Added auto-applied cmake submodule patches for Qt 6.11 compatibility. --- .gitignore | 1 + CMakeLists.txt | 23 +++++++++++ Telegram/build/prepare/prepare.py | 12 +++++- Telegram/build/qt_version.py | 2 +- cmake | 2 +- patches/cmake_qt611.patch | 69 +++++++++++++++++++++++++++++++ 6 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 patches/cmake_qt611.patch diff --git a/.gitignore b/.gitignore index 8547c2aa0b..4da55962c4 100644 --- a/.gitignore +++ b/.gitignore @@ -53,6 +53,7 @@ stage *.*~ .idea/ cmake-build-debug/ +*.qsb # Local configuration files settings.local.json diff --git a/CMakeLists.txt b/CMakeLists.txt index e762a3cd59..e72589fadf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,29 @@ cmake_minimum_required(VERSION 3.25...3.31) set_property(GLOBAL PROPERTY USE_FOLDERS ON) +# Apply qt6.11 patches to submodules at configure time. +file(GLOB _submodule_patches "${CMAKE_SOURCE_DIR}/patches/*.patch") +foreach(_patch ${_submodule_patches}) + get_filename_component(_patch_name ${_patch} NAME) + # Extract target submodule directory from patch filename (prefix before first '_'). + string(REGEX MATCH "^([a-z]+)" _submodule ${_patch_name}) + if (IS_DIRECTORY "${CMAKE_SOURCE_DIR}/${_submodule}") + execute_process( + COMMAND git apply --check ${_patch} + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/${_submodule}" + RESULT_VARIABLE _check_result + OUTPUT_QUIET ERROR_QUIET + ) + if (_check_result EQUAL 0) + execute_process( + COMMAND git apply ${_patch} + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/${_submodule}" + ) + message(STATUS "Applied patch: ${_patch_name}") + endif() + endif() +endforeach() + include(cmake/validate_special_target.cmake) include(cmake/version.cmake) desktop_app_parse_version(Telegram/build/version) diff --git a/Telegram/build/prepare/prepare.py b/Telegram/build/prepare/prepare.py index 7e436d8df4..9128ee59db 100644 --- a/Telegram/build/prepare/prepare.py +++ b/Telegram/build/prepare/prepare.py @@ -1554,6 +1554,10 @@ win: jom -j%NUMBER_OF_PROCESSORS% install mac: find ../../patches/qtbase_$QT -type f -print0 | sort -z | xargs -0 git apply + QT_MAJOR_MINOR=$(echo $QT | grep -oE '^[0-9]+\\.[0-9]+') + if [ -d "../../patches/qt6_highsierra/$QT_MAJOR_MINOR" ]; then + find "../../patches/qt6_highsierra/$QT_MAJOR_MINOR" -type f -print0 | sort -z | xargs -0 git apply + fi cd .. CONFIGURATIONS=-debug @@ -1588,6 +1592,10 @@ else: # qt > '6' depends:patches/qtbase_""" + qt + """/*.patch cd qtbase mac: + QT_MAJOR_MINOR=$(echo $QT | grep -oE '^[0-9]+\\.[0-9]+') + if [ -d "../../patches/qt6_highsierra/$QT_MAJOR_MINOR" ]; then + find "../../patches/qt6_highsierra/$QT_MAJOR_MINOR" -type f -print0 | sort -z | xargs -0 git apply -v + fi find ../../patches/qtbase_$QT -type f -print0 | sort -z | xargs -0 git apply -v cd .. sed -i.bak 's/tqtc-//' {qtimageformats,qtsvg}/dependencies.yaml @@ -1602,6 +1610,7 @@ mac: -opensource \ -confirm-license \ -static \ + -no-framework \ -opengl desktop \ -no-openssl \ -securetransport \ @@ -1611,7 +1620,8 @@ mac: -no-feature-brotli \ -platform macx-clang -- \ -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" \ - -DCMAKE_PREFIX_PATH="$USED_PREFIX" + -DCMAKE_PREFIX_PATH="$USED_PREFIX" \ + -DQT_SYNC_HEADERS_AT_CONFIGURE_TIME=ON cmake --build . cmake --install . diff --git a/Telegram/build/qt_version.py b/Telegram/build/qt_version.py index f3678ed185..98228adef0 100644 --- a/Telegram/build/qt_version.py +++ b/Telegram/build/qt_version.py @@ -2,7 +2,7 @@ import sys, os def resolve(arch): if sys.platform == 'darwin': - os.environ['QT'] = '6.2.13' + os.environ['QT'] = '6.11.0' elif sys.platform == 'win32': if arch == 'arm' or 'qt6' in sys.argv: print('Choosing Qt 6.') diff --git a/cmake b/cmake index 66f6a0318c..4088db229d 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit 66f6a0318cf1fdd91c52b1cb11c638e0b6b6a0a6 +Subproject commit 4088db229d9132e1ff2e6758ad7ae28e5116fea6 diff --git a/patches/cmake_qt611.patch b/patches/cmake_qt611.patch new file mode 100644 index 0000000000..0e7d2b1a68 --- /dev/null +++ b/patches/cmake_qt611.patch @@ -0,0 +1,69 @@ +From 982e3ecbcf9a874bd5f82433f514f3175a84eeb1 Mon Sep 17 00:00:00 2001 +From: 23rd <23rd@vivaldi.net> +Date: Wed, 1 Apr 2026 09:06:36 +0300 +Subject: [PATCH] 1 + +--- + external/qt/CMakeLists.txt | 22 ++++++++++++++++++++-- + options_mac.cmake | 11 +++++++++++ + 2 files changed, 31 insertions(+), 2 deletions(-) + +diff --git a/external/qt/CMakeLists.txt b/external/qt/CMakeLists.txt +index 577b67b..9845f55 100644 +--- a/external/qt/CMakeLists.txt ++++ b/external/qt/CMakeLists.txt +@@ -234,12 +234,30 @@ elseif (APPLE) + lib/${qt_lib_prefix}Qt${QT_VERSION_MAJOR}BundledFreetype + plugins/platforms/${qt_lib_prefix}qcocoa + plugins/tls/${qt_lib_prefix}qsecuretransportbackend +- plugins/networkinformation/${qt_lib_prefix}qscnetworkreachability + ) ++ if (QT_VERSION VERSION_GREATER_EQUAL "6.11") ++ list(APPEND qt_libs ++ plugins/networkinformation/${qt_lib_prefix}qapplenetworkinformation ++ ) ++ else() ++ list(APPEND qt_libs ++ plugins/networkinformation/${qt_lib_prefix}qscnetworkreachability ++ ) ++ endif() + list(APPEND qt_libs_list + $ + $ +- $ ++ ) ++ if (QT_VERSION VERSION_GREATER_EQUAL "6.11") ++ list(APPEND qt_libs_list ++ $ ++ ) ++ else() ++ list(APPEND qt_libs_list ++ $ ++ ) ++ endif() ++ list(APPEND qt_libs_list + $ + ) + foreach (lib ${qt_libs}) +diff --git a/options_mac.cmake b/options_mac.cmake +index 59494d8..73960ad 100644 +--- a/options_mac.cmake ++++ b/options_mac.cmake +@@ -80,3 +80,14 @@ INTERFACE + LocalAuthentication + Vision + ) ++ ++target_link_frameworks_weak(common_options ++INTERFACE ++ Network ++ UniformTypeIdentifiers ++) ++ ++target_link_libraries(common_options ++INTERFACE ++ resolv ++) +-- +2.50.1 (Apple Git-155) +