From f3a611c82bfee860f950d5ca6563d8d68262b38d Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 28 Sep 2021 18:44:05 +0400 Subject: [PATCH 01/34] Add some hardening compiler / linker flags. --- external/jemalloc/CMakeLists.txt | 2 +- linux_glib_helper/CMakeLists.txt | 1 + linux_gtk_helper/CMakeLists.txt | 1 + linux_wayland_helper/CMakeLists.txt | 1 + options_linux.cmake | 10 ++++++++++ 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/external/jemalloc/CMakeLists.txt b/external/jemalloc/CMakeLists.txt index 0c0f0be..014dc4f 100644 --- a/external/jemalloc/CMakeLists.txt +++ b/external/jemalloc/CMakeLists.txt @@ -33,7 +33,7 @@ if (NOT JEMALLOC_FOUND) include(ExternalProject) ExternalProject_Add(jemalloc SOURCE_DIR ${jemalloc_loc} - CONFIGURE_COMMAND cd "${jemalloc_loc}" && CC=clang CXX=clang++ EXTRA_CFLAGS=-fPIE EXTRA_CXXFLAGS=-fPIE ./autogen.sh + CONFIGURE_COMMAND cd "${jemalloc_loc}" && export EXTRA_CFLAGS=-fstack-protector-all\ -fPIC\ -D_FORTIFY_SOURCE=2 && export EXTRA_CXXFLAGS=-fstack-protector-all\ -fPIC\ -D_FORTIFY_SOURCE=2 && CC=clang CXX=clang++ ./autogen.sh INSTALL_COMMAND : BUILD_IN_SOURCE 1 BUILD_BYPRODUCTS ${jemalloc_loc}/lib/libjemalloc.a diff --git a/linux_glib_helper/CMakeLists.txt b/linux_glib_helper/CMakeLists.txt index f3a4d13..3d8ea91 100644 --- a/linux_glib_helper/CMakeLists.txt +++ b/linux_glib_helper/CMakeLists.txt @@ -5,6 +5,7 @@ # https://github.com/desktop-app/legal/blob/master/LEGAL add_library(linux_glib_helper STATIC) +init_target(linux_glib_helper "(external)") add_library(desktop-app::linux_glib_helper ALIAS linux_glib_helper) nice_target_sources(linux_glib_helper ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/linux_gtk_helper/CMakeLists.txt b/linux_gtk_helper/CMakeLists.txt index 753111e..e5708d3 100644 --- a/linux_gtk_helper/CMakeLists.txt +++ b/linux_gtk_helper/CMakeLists.txt @@ -5,6 +5,7 @@ # https://github.com/desktop-app/legal/blob/master/LEGAL add_library(linux_gtk_helper STATIC) +init_target(linux_gtk_helper "(external)") add_library(desktop-app::linux_gtk_helper ALIAS linux_gtk_helper) nice_target_sources(linux_gtk_helper ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/linux_wayland_helper/CMakeLists.txt b/linux_wayland_helper/CMakeLists.txt index 7f7d8d3..02205ba 100644 --- a/linux_wayland_helper/CMakeLists.txt +++ b/linux_wayland_helper/CMakeLists.txt @@ -5,6 +5,7 @@ # https://github.com/desktop-app/legal/blob/master/LEGAL add_library(linux_wayland_helper STATIC) +init_target(linux_wayland_helper "(external)") add_library(desktop-app::linux_wayland_helper ALIAS linux_wayland_helper) nice_target_sources(linux_wayland_helper ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/options_linux.cmake b/options_linux.cmake index 2797c7b..4765a39 100644 --- a/options_linux.cmake +++ b/options_linux.cmake @@ -6,6 +6,8 @@ target_compile_options(common_options INTERFACE + -fstack-protector-all + -fstack-clash-protection -fPIC $,,-fno-strict-aliasing> -pipe @@ -17,9 +19,17 @@ INTERFACE -Wno-sign-compare ) +target_compile_definitions(common_options +INTERFACE + $,,_FORTIFY_SOURCE=2> +) + target_link_options(common_options INTERFACE -Wl,--as-needed + -Wl,-z,relro + -Wl,-z,now + -pie ) if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") From c4c2bf4bada5207570a78fa3541907a1e9e7bda5 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 28 Sep 2021 21:08:35 +0400 Subject: [PATCH 02/34] Link UxTheme.lib on Windows. --- options_win.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/options_win.cmake b/options_win.cmake index 6370964..ad3c46d 100644 --- a/options_win.cmake +++ b/options_win.cmake @@ -105,6 +105,7 @@ INTERFACE Userenv Version Dwmapi + UxTheme Wtsapi32 Crypt32 ) From 18d7c34ce1218be6852e5486fdcf81e67395b996 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 28 Sep 2021 22:07:29 +0400 Subject: [PATCH 03/34] Hardening flags only for non-packaged builds. --- options_linux.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/options_linux.cmake b/options_linux.cmake index 4765a39..35b8d5d 100644 --- a/options_linux.cmake +++ b/options_linux.cmake @@ -27,9 +27,6 @@ INTERFACE target_link_options(common_options INTERFACE -Wl,--as-needed - -Wl,-z,relro - -Wl,-z,now - -pie ) if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") @@ -106,6 +103,9 @@ if (NOT DESKTOP_APP_USE_PACKAGED) -pthread -rdynamic -fwhole-program + -Wl,-z,relro + -Wl,-z,now + -pie ) endif() From 5c32bf152f7b83d4a8e53366a1531a7305bc6d40 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Wed, 29 Sep 2021 03:12:41 +0400 Subject: [PATCH 04/34] Set compiler flags of other XCode attributes (look at 872027e466611376db002709ce3db4b6dd432808) --- options_mac.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/options_mac.cmake b/options_mac.cmake index ae73cc2..80ffb3d 100644 --- a/options_mac.cmake +++ b/options_mac.cmake @@ -25,6 +25,8 @@ INTERFACE -W -fPIE $<$:-fobjc-weak> + -fvisibility-inlines-hidden + -fvisibility=hidden -Wno-deprecated-declarations # temp for range-v3 -Wno-unused-variable -Wno-unused-parameter From 2b7b92f30bd5c723562e1002375981b455700487 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 5 Oct 2021 21:58:06 +0400 Subject: [PATCH 05/34] Link PropSys.lib on Windows. --- options_win.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/options_win.cmake b/options_win.cmake index ad3c46d..b2eeefa 100644 --- a/options_win.cmake +++ b/options_win.cmake @@ -108,6 +108,7 @@ INTERFACE UxTheme Wtsapi32 Crypt32 + Propsys ) if (build_winstore) From f77251b2c100dd5af713333f29d94ae10960279a Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 6 Oct 2021 20:35:08 +0400 Subject: [PATCH 06/34] Remove -Wl,-z,now from the linker flags. --- options_linux.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/options_linux.cmake b/options_linux.cmake index 35b8d5d..e7f2210 100644 --- a/options_linux.cmake +++ b/options_linux.cmake @@ -104,7 +104,6 @@ if (NOT DESKTOP_APP_USE_PACKAGED) -rdynamic -fwhole-program -Wl,-z,relro - -Wl,-z,now -pie ) endif() From 13575af1f3b4bca559a1f57f89197dcd4d07d882 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 8 Oct 2021 10:25:32 +0400 Subject: [PATCH 07/34] Remove -pie linker flag. See https://gitlab.gnome.org/GNOME/nautilus/-/issues/1601 --- options_linux.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/options_linux.cmake b/options_linux.cmake index e7f2210..24f0e0e 100644 --- a/options_linux.cmake +++ b/options_linux.cmake @@ -104,7 +104,7 @@ if (NOT DESKTOP_APP_USE_PACKAGED) -rdynamic -fwhole-program -Wl,-z,relro - -pie + # -pie # https://gitlab.gnome.org/GNOME/nautilus/-/issues/1601 ) endif() From 9adb6a5efc6d8ae9ab5e8e2e69a557c2b49445c7 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Tue, 19 Oct 2021 17:08:14 +0400 Subject: [PATCH 08/34] fcitx5_qt5 -> fcitx5_qt --- external/CMakeLists.txt | 2 +- .../{fcitx5_qt5 => fcitx5_qt}/CMakeLists.txt | 36 +++++++++---------- .../fcitx5_qt_dbusaddons}/CMakeLists.txt | 26 +++++++------- external/qt/qt_static_plugins/CMakeLists.txt | 2 +- 4 files changed, 33 insertions(+), 33 deletions(-) rename external/{fcitx5_qt5 => fcitx5_qt}/CMakeLists.txt (57%) rename external/{fcitx5_qt5/fcitx5_qt5_dbusaddons => fcitx5_qt/fcitx5_qt_dbusaddons}/CMakeLists.txt (50%) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 58ba80a..1460cf9 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -21,7 +21,7 @@ add_checked_subdirectory(expected) if (LINUX AND NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION) add_checked_subdirectory(fcitx_qt5) if (NOT DESKTOP_APP_DISABLE_X11_INTEGRATION) - add_checked_subdirectory(fcitx5_qt5) + add_checked_subdirectory(fcitx5_qt) endif() endif() add_checked_subdirectory(ffmpeg) diff --git a/external/fcitx5_qt5/CMakeLists.txt b/external/fcitx5_qt/CMakeLists.txt similarity index 57% rename from external/fcitx5_qt5/CMakeLists.txt rename to external/fcitx5_qt/CMakeLists.txt index 2d57f29..0058582 100644 --- a/external/fcitx5_qt5/CMakeLists.txt +++ b/external/fcitx5_qt/CMakeLists.txt @@ -5,22 +5,22 @@ # https://github.com/desktop-app/legal/blob/master/LEGAL if (DESKTOP_APP_USE_PACKAGED AND NOT DESKTOP_APP_USE_PACKAGED_LAZY) - add_library(external_fcitx5_qt5 INTERFACE IMPORTED GLOBAL) - add_library(desktop-app::external_fcitx5_qt5 ALIAS external_fcitx5_qt5) + add_library(external_fcitx5_qt INTERFACE IMPORTED GLOBAL) + add_library(desktop-app::external_fcitx5_qt ALIAS external_fcitx5_qt) else() - add_library(external_fcitx5_qt5 STATIC) - add_library(desktop-app::external_fcitx5_qt5 ALIAS external_fcitx5_qt5) - init_target(external_fcitx5_qt5 "(external)") + add_library(external_fcitx5_qt STATIC) + add_library(desktop-app::external_fcitx5_qt ALIAS external_fcitx5_qt) + init_target(external_fcitx5_qt "(external)") set(fcitx5_qt_loc ${third_party_loc}/fcitx5-qt) - set(fcitx5_qt5_src ${fcitx5_qt_loc}/qt5/platforminputcontext) + set(fcitx5_qt_src ${fcitx5_qt_loc}/qt5/platforminputcontext) - set_target_properties(external_fcitx5_qt5 PROPERTIES AUTOMOC ON) + set_target_properties(external_fcitx5_qt PROPERTIES AUTOMOC ON) set(FCITX5_QT_EXTRA_PLUGIN_NAME "") - configure_file("${fcitx5_qt5_src}/fcitx5.json.in" "${CMAKE_CURRENT_BINARY_DIR}/fcitx5.json") + configure_file("${fcitx5_qt_src}/fcitx5.json.in" "${CMAKE_CURRENT_BINARY_DIR}/fcitx5.json") - nice_target_sources(external_fcitx5_qt5 ${fcitx5_qt5_src} + nice_target_sources(external_fcitx5_qt ${fcitx5_qt_src} PRIVATE qfcitxplatforminputcontext.cpp qfcitxplatforminputcontext.h @@ -35,22 +35,22 @@ else() main.h ) - target_include_directories(external_fcitx5_qt5 + target_include_directories(external_fcitx5_qt PRIVATE - ${fcitx5_qt5_src} + ${fcitx5_qt_src} ${fcitx5_qt_loc}/common ) - target_compile_definitions(external_fcitx5_qt5 + target_compile_definitions(external_fcitx5_qt PRIVATE QT_STATICPLUGIN FCITX_PLUGIN_DATA_FILE_PATH="${CMAKE_CURRENT_BINARY_DIR}/fcitx5.json" ) - add_subdirectory(fcitx5_qt5_dbusaddons) - target_link_libraries(external_fcitx5_qt5 + add_subdirectory(fcitx5_qt_dbusaddons) + target_link_libraries(external_fcitx5_qt PRIVATE - desktop-app::external_fcitx5_qt5_dbusaddons + desktop-app::external_fcitx5_qt_dbusaddons desktop-app::external_qt desktop-app::external_xcb ) @@ -59,7 +59,7 @@ else() find_package(PkgConfig REQUIRED) pkg_check_modules(XKBCOMMON REQUIRED IMPORTED_TARGET xkbcommon) - target_link_libraries(external_fcitx5_qt5 + target_link_libraries(external_fcitx5_qt PRIVATE PkgConfig::XKBCOMMON ) @@ -67,12 +67,12 @@ else() find_package(PkgConfig REQUIRED) pkg_check_modules(XKBCOMMON REQUIRED xkbcommon) - target_include_directories(external_fcitx5_qt5 SYSTEM + target_include_directories(external_fcitx5_qt SYSTEM PUBLIC ${XKBCOMMON_INCLUDE_DIRS} ) - target_link_static_libraries(external_fcitx5_qt5 + target_link_static_libraries(external_fcitx5_qt PRIVATE xkbcommon ) diff --git a/external/fcitx5_qt5/fcitx5_qt5_dbusaddons/CMakeLists.txt b/external/fcitx5_qt/fcitx5_qt_dbusaddons/CMakeLists.txt similarity index 50% rename from external/fcitx5_qt5/fcitx5_qt5_dbusaddons/CMakeLists.txt rename to external/fcitx5_qt/fcitx5_qt_dbusaddons/CMakeLists.txt index 9af7e3e..be7cfe1 100644 --- a/external/fcitx5_qt5/fcitx5_qt5_dbusaddons/CMakeLists.txt +++ b/external/fcitx5_qt/fcitx5_qt_dbusaddons/CMakeLists.txt @@ -5,19 +5,19 @@ # https://github.com/desktop-app/legal/blob/master/LEGAL if (DESKTOP_APP_USE_PACKAGED AND NOT DESKTOP_APP_USE_PACKAGED_LAZY) - add_library(external_fcitx5_qt5_dbusaddons INTERFACE IMPORTED GLOBAL) - add_library(desktop-app::external_fcitx5_qt5_dbusaddons ALIAS external_fcitx5_qt5_dbusaddons) + add_library(external_fcitx5_qt_dbusaddons INTERFACE IMPORTED GLOBAL) + add_library(desktop-app::external_fcitx5_qt_dbusaddons ALIAS external_fcitx5_qt_dbusaddons) else() - add_library(external_fcitx5_qt5_dbusaddons STATIC) - add_library(desktop-app::external_fcitx5_qt5_dbusaddons ALIAS external_fcitx5_qt5_dbusaddons) - init_target(external_fcitx5_qt5_dbusaddons "(external)") + add_library(external_fcitx5_qt_dbusaddons STATIC) + add_library(desktop-app::external_fcitx5_qt_dbusaddons ALIAS external_fcitx5_qt_dbusaddons) + init_target(external_fcitx5_qt_dbusaddons "(external)") set(fcitx5_qt_loc ${third_party_loc}/fcitx5-qt) - set(fcitx5_qt5_dbusaddons_src ${fcitx5_qt_loc}/qt5/dbusaddons) + set(fcitx5_qt_dbusaddons_src ${fcitx5_qt_loc}/qt5/dbusaddons) - set_target_properties(external_fcitx5_qt5_dbusaddons PROPERTIES AUTOMOC ON) + set_target_properties(external_fcitx5_qt_dbusaddons PROPERTIES AUTOMOC ON) - nice_target_sources(external_fcitx5_qt5_dbusaddons ${fcitx5_qt5_dbusaddons_src} + nice_target_sources(external_fcitx5_qt_dbusaddons ${fcitx5_qt_dbusaddons_src} PRIVATE fcitxqtwatcher.cpp fcitxqtwatcher.h @@ -33,20 +33,20 @@ else() ) include(GenerateExportHeader) - generate_export_header(external_fcitx5_qt5_dbusaddons BASE_NAME Fcitx5Qt5DBusAddons) + generate_export_header(external_fcitx5_qt_dbusaddons BASE_NAME Fcitx5Qt5DBusAddons) - target_include_directories(external_fcitx5_qt5_dbusaddons + target_include_directories(external_fcitx5_qt_dbusaddons PUBLIC - ${fcitx5_qt5_dbusaddons_src} + ${fcitx5_qt_dbusaddons_src} "${CMAKE_CURRENT_BINARY_DIR}" ) - target_compile_definitions(external_fcitx5_qt5_dbusaddons + target_compile_definitions(external_fcitx5_qt_dbusaddons PRIVATE FCITX5QT5DBUSADDONS_STATIC_DEFINE ) - target_link_libraries(external_fcitx5_qt5_dbusaddons + target_link_libraries(external_fcitx5_qt_dbusaddons PRIVATE desktop-app::external_qt ) diff --git a/external/qt/qt_static_plugins/CMakeLists.txt b/external/qt/qt_static_plugins/CMakeLists.txt index 4cbb27b..7a8651a 100644 --- a/external/qt/qt_static_plugins/CMakeLists.txt +++ b/external/qt/qt_static_plugins/CMakeLists.txt @@ -33,7 +33,7 @@ if (LINUX) if (NOT DESKTOP_APP_DISABLE_X11_INTEGRATION) target_link_libraries(external_qt_static_plugins PUBLIC - desktop-app::external_fcitx5_qt5 + desktop-app::external_fcitx5_qt ) endif() endif() From c4e45be16cebb104ff497eedb8df283cc1acd60e Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Tue, 19 Oct 2021 17:08:32 +0400 Subject: [PATCH 09/34] Don't link deprecated wl-shell --- external/qt/CMakeLists.txt | 1 - external/qt/qt_static_plugins/qt_static_plugins.cpp | 4 ---- 2 files changed, 5 deletions(-) diff --git a/external/qt/CMakeLists.txt b/external/qt/CMakeLists.txt index 935c144..5c25aa1 100644 --- a/external/qt/CMakeLists.txt +++ b/external/qt/CMakeLists.txt @@ -208,7 +208,6 @@ else() plugins/platforms/${qt_lib_prefix}qwayland-generic plugins/platforms/${qt_lib_prefix}qwayland-egl plugins/wayland-graphics-integration-client/${qt_lib_prefix}qt-plugin-wayland-egl - plugins/wayland-shell-integration/${qt_lib_prefix}wl-shell plugins/wayland-decoration-client/${qt_lib_prefix}bradient ) endif() diff --git a/external/qt/qt_static_plugins/qt_static_plugins.cpp b/external/qt/qt_static_plugins/qt_static_plugins.cpp index 9bbb617..25fc093 100644 --- a/external/qt/qt_static_plugins/qt_static_plugins.cpp +++ b/external/qt/qt_static_plugins/qt_static_plugins.cpp @@ -10,11 +10,8 @@ https://github.com/desktop-app/legal/blob/master/LEGAL #ifndef DESKTOP_APP_USE_PACKAGED Q_IMPORT_PLUGIN(QGenericEnginePlugin) Q_IMPORT_PLUGIN(QWebpPlugin) - -#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) Q_IMPORT_PLUGIN(QJpegPlugin) Q_IMPORT_PLUGIN(QGifPlugin) -#endif // Qt 5.8.0 #ifdef Q_OS_WIN Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin) @@ -35,7 +32,6 @@ Q_IMPORT_PLUGIN(QIbusPlatformInputContextPlugin) Q_IMPORT_PLUGIN(QWaylandIntegrationPlugin) Q_IMPORT_PLUGIN(QWaylandEglPlatformIntegrationPlugin) Q_IMPORT_PLUGIN(QWaylandEglClientBufferPlugin) -Q_IMPORT_PLUGIN(QWaylandWlShellIntegrationPlugin) Q_IMPORT_PLUGIN(QWaylandBradientDecorationPlugin) #endif // !DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION Q_IMPORT_PLUGIN(QGtk3ThemePlugin) From a8856aa831a8f70e724ae5d04b6b4a37eb538940 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Wed, 20 Oct 2021 14:47:09 +0400 Subject: [PATCH 10/34] Add Qt 6 support Tested on Linux only --- CMakeLists.txt | 2 +- external/CMakeLists.txt | 12 +- external/fcitx5_qt/CMakeLists.txt | 14 +- .../fcitx5_qt_dbusaddons/CMakeLists.txt | 24 +- external/qt/CMakeLists.txt | 8 +- external/qt/package.cmake | 39 ++- external/qt/qt6/CMakeLists.txt | 276 ++++++++++++++++++ external/qt/qt_static_plugins/CMakeLists.txt | 12 +- .../qt_static_plugins/qt_static_plugins.cpp | 9 + linux_glib_helper/linux_glib_helper.cpp | 8 + options.cmake | 1 + variables.cmake | 1 + 12 files changed, 375 insertions(+), 31 deletions(-) create mode 100644 external/qt/qt6/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index cf0834a..95b0f6b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ add_subdirectory(external) if (LINUX AND NOT DESKTOP_APP_USE_PACKAGED - AND Qt5WaylandClient_FOUND) + AND NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) add_subdirectory(linux_wayland_helper) endif() if (LINUX AND NOT DESKTOP_APP_USE_PACKAGED) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 1460cf9..633ceb5 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -14,12 +14,14 @@ endmacro() add_checked_subdirectory(angle) add_checked_subdirectory(auto_updates) add_checked_subdirectory(crash_reports) -if (LINUX AND NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION) +if (LINUX AND NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION AND NOT DESKTOP_APP_QT6) add_checked_subdirectory(dbusmenu_qt) endif() add_checked_subdirectory(expected) if (LINUX AND NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION) - add_checked_subdirectory(fcitx_qt5) + if (NOT DESKTOP_APP_QT6) + add_checked_subdirectory(fcitx_qt5) + endif() if (NOT DESKTOP_APP_DISABLE_X11_INTEGRATION) add_checked_subdirectory(fcitx5_qt) endif() @@ -30,7 +32,7 @@ if (LINUX AND NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION) add_checked_subdirectory(glibmm) endif() add_checked_subdirectory(gsl) -if (LINUX AND NOT DESKTOP_APP_DISABLE_X11_INTEGRATION) +if (LINUX AND NOT DESKTOP_APP_DISABLE_X11_INTEGRATION AND NOT DESKTOP_APP_QT6) add_checked_subdirectory(hime_qt) endif() if (add_hunspell_library) @@ -41,7 +43,7 @@ if (LINUX) add_checked_subdirectory(jemalloc) endif() add_checked_subdirectory(jpeg) -if (LINUX AND NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) +if (LINUX AND NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION AND NOT DESKTOP_APP_QT6) add_checked_subdirectory(kwayland) endif() add_checked_subdirectory(lz4) @@ -57,7 +59,7 @@ add_checked_subdirectory(qr_code_generator) add_checked_subdirectory(ranges) add_checked_subdirectory(rlottie) add_checked_subdirectory(rnnoise) -if (LINUX AND NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION) +if (LINUX AND NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION AND NOT DESKTOP_APP_QT6) add_checked_subdirectory(statusnotifieritem) endif() add_checked_subdirectory(ton) diff --git a/external/fcitx5_qt/CMakeLists.txt b/external/fcitx5_qt/CMakeLists.txt index 0058582..cc3ead4 100644 --- a/external/fcitx5_qt/CMakeLists.txt +++ b/external/fcitx5_qt/CMakeLists.txt @@ -13,11 +13,21 @@ else() init_target(external_fcitx5_qt "(external)") set(fcitx5_qt_loc ${third_party_loc}/fcitx5-qt) - set(fcitx5_qt_src ${fcitx5_qt_loc}/qt5/platforminputcontext) + + if (DESKTOP_APP_QT6) + set(fcitx5_qt_src ${fcitx5_qt_loc}/qt6/platforminputcontext) + else() + set(fcitx5_qt_src ${fcitx5_qt_loc}/qt5/platforminputcontext) + endif() set_target_properties(external_fcitx5_qt PROPERTIES AUTOMOC ON) - set(FCITX5_QT_EXTRA_PLUGIN_NAME "") + if (DESKTOP_APP_QT6) + set(FCITX5_QT_EXTRA_PLUGIN_NAME "\"fcitx\",") + else() + set(FCITX5_QT_EXTRA_PLUGIN_NAME "") + endif() + configure_file("${fcitx5_qt_src}/fcitx5.json.in" "${CMAKE_CURRENT_BINARY_DIR}/fcitx5.json") nice_target_sources(external_fcitx5_qt ${fcitx5_qt_src} diff --git a/external/fcitx5_qt/fcitx5_qt_dbusaddons/CMakeLists.txt b/external/fcitx5_qt/fcitx5_qt_dbusaddons/CMakeLists.txt index be7cfe1..9b15c46 100644 --- a/external/fcitx5_qt/fcitx5_qt_dbusaddons/CMakeLists.txt +++ b/external/fcitx5_qt/fcitx5_qt_dbusaddons/CMakeLists.txt @@ -13,7 +13,12 @@ else() init_target(external_fcitx5_qt_dbusaddons "(external)") set(fcitx5_qt_loc ${third_party_loc}/fcitx5-qt) - set(fcitx5_qt_dbusaddons_src ${fcitx5_qt_loc}/qt5/dbusaddons) + + if (DESKTOP_APP_QT6) + set(fcitx5_qt_dbusaddons_src ${fcitx5_qt_loc}/qt6/dbusaddons) + else() + set(fcitx5_qt_dbusaddons_src ${fcitx5_qt_loc}/qt5/dbusaddons) + endif() set_target_properties(external_fcitx5_qt_dbusaddons PROPERTIES AUTOMOC ON) @@ -33,7 +38,12 @@ else() ) include(GenerateExportHeader) - generate_export_header(external_fcitx5_qt_dbusaddons BASE_NAME Fcitx5Qt5DBusAddons) + + if (DESKTOP_APP_QT6) + generate_export_header(external_fcitx5_qt_dbusaddons BASE_NAME Fcitx5Qt6DBusAddons) + else() + generate_export_header(external_fcitx5_qt_dbusaddons BASE_NAME Fcitx5Qt5DBusAddons) + endif() target_include_directories(external_fcitx5_qt_dbusaddons PUBLIC @@ -41,10 +51,12 @@ else() "${CMAKE_CURRENT_BINARY_DIR}" ) - target_compile_definitions(external_fcitx5_qt_dbusaddons - PRIVATE - FCITX5QT5DBUSADDONS_STATIC_DEFINE - ) + if (NOT DESKTOP_APP_QT6) + target_compile_definitions(external_fcitx5_qt_dbusaddons + PRIVATE + FCITX5QT5DBUSADDONS_STATIC_DEFINE + ) + endif() target_link_libraries(external_fcitx5_qt_dbusaddons PRIVATE diff --git a/external/qt/CMakeLists.txt b/external/qt/CMakeLists.txt index 5c25aa1..f1649ad 100644 --- a/external/qt/CMakeLists.txt +++ b/external/qt/CMakeLists.txt @@ -4,11 +4,15 @@ # For license and copyright information please follow this link: # https://github.com/desktop-app/legal/blob/master/LEGAL +add_subdirectory(qt_static_plugins) +if (DESKTOP_APP_QT6) + add_subdirectory(qt6) + return() +endif() + add_library(external_qt INTERFACE IMPORTED GLOBAL) add_library(desktop-app::external_qt ALIAS external_qt) -add_subdirectory(qt_static_plugins) - if (DESKTOP_APP_USE_PACKAGED) target_link_libraries(external_qt INTERFACE diff --git a/external/qt/package.cmake b/external/qt/package.cmake index 3169cbe..7a778d8 100644 --- a/external/qt/package.cmake +++ b/external/qt/package.cmake @@ -5,7 +5,11 @@ # https://github.com/desktop-app/legal/blob/master/LEGAL if (NOT DESKTOP_APP_USE_PACKAGED) - set(qt_version 5.15.2) + if (DESKTOP_APP_QT6) + set(qt_version 6.2.0) + else() + set(qt_version 5.15.2) + endif() if (WIN32) set(qt_loc ${libs_loc}/Qt-${qt_version}) @@ -15,22 +19,37 @@ if (NOT DESKTOP_APP_USE_PACKAGED) set(qt_loc /usr/local/desktop-app/Qt-${qt_version}) endif() - set(Qt5_DIR ${qt_loc}/lib/cmake/Qt5) + set(CMAKE_PREFIX_PATH ${qt_loc}) endif() -find_package(Qt5 COMPONENTS Core Gui Widgets Network Svg REQUIRED) -find_package(Qt5Gui COMPONENTS QWebpPlugin REQUIRED) +if (DESKTOP_APP_QT6) + find_package(Qt6 COMPONENTS Core Core5Compat Gui OpenGL Widgets OpenGLWidgets Network Svg REQUIRED) +else() + find_package(Qt5 COMPONENTS Core Gui Widgets Network Svg REQUIRED) +endif() if (LINUX) if (NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) - find_package(Qt5 COMPONENTS WaylandClient REQUIRED) - find_package(Qt5 OPTIONAL_COMPONENTS XkbCommonSupport QUIET) + if (DESKTOP_APP_QT6) + find_package(Qt6 COMPONENTS WaylandClient REQUIRED) + else() + find_package(Qt5 COMPONENTS WaylandClient REQUIRED) + find_package(Qt5 OPTIONAL_COMPONENTS XkbCommonSupport QUIET) + endif() endif() - if (DESKTOP_APP_DISABLE_DBUS_INTEGRATION) - find_package(Qt5 OPTIONAL_COMPONENTS DBus QUIET) - else() - find_package(Qt5 COMPONENTS DBus REQUIRED) + if (NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION) + if (DESKTOP_APP_QT6) + find_package(Qt6 COMPONENTS DBus REQUIRED) + else() + find_package(Qt5 COMPONENTS DBus REQUIRED) + endif() + elseif (NOT DESKTOP_APP_USE_PACKAGED) + if (DESKTOP_APP_QT6) + find_package(Qt6 OPTIONAL_COMPONENTS DBus QUIET) + else() + find_package(Qt5 OPTIONAL_COMPONENTS DBus QUIET) + endif() endif() endif() diff --git a/external/qt/qt6/CMakeLists.txt b/external/qt/qt6/CMakeLists.txt new file mode 100644 index 0000000..8426de7 --- /dev/null +++ b/external/qt/qt6/CMakeLists.txt @@ -0,0 +1,276 @@ +# This file is part of Desktop App Toolkit, +# a set of libraries for developing nice desktop applications. +# +# For license and copyright information please follow this link: +# https://github.com/desktop-app/legal/blob/master/LEGAL + +add_library(external_qt INTERFACE IMPORTED GLOBAL) +add_library(desktop-app::external_qt ALIAS external_qt) + +if (DESKTOP_APP_USE_PACKAGED) + target_link_libraries(external_qt + INTERFACE + Qt6::Core + Qt6::Core5Compat + Qt6::Gui + Qt6::OpenGL + Qt6::Widgets + Qt6::OpenGLWidgets + Qt6::Network + Qt6::Svg + ) + + target_include_directories(external_qt SYSTEM + INTERFACE + ${Qt6Core_PRIVATE_INCLUDE_DIRS} + ${Qt6Gui_PRIVATE_INCLUDE_DIRS} + ) + + if (Qt6DBus_FOUND) + target_link_libraries(external_qt INTERFACE Qt6::DBus) + endif() + + if (Qt6WaylandClient_FOUND) + target_link_libraries(external_qt INTERFACE Qt6::WaylandClient) + + target_include_directories(external_qt SYSTEM + INTERFACE + ${Qt6WaylandClient_PRIVATE_INCLUDE_DIRS} + ) + endif() +else() + target_include_directories(external_qt SYSTEM + INTERFACE + ${qt_loc}/include + ${qt_loc}/include/QtCore + ${qt_loc}/include/QtCore5Compat + ${qt_loc}/include/QtGui + ${qt_loc}/include/QtOpenGL + ${qt_loc}/include/QtWidgets + ${qt_loc}/include/QtOpenGLWidgets + ${qt_loc}/include/QtSvg + ${qt_loc}/include/QtCore/${qt_version} + ${qt_loc}/include/QtGui/${qt_version} + ${qt_loc}/include/QtCore/${qt_version}/QtCore + ${qt_loc}/include/QtGui/${qt_version}/QtGui + ) + + if (Qt6DBus_FOUND) + target_include_directories(external_qt SYSTEM + INTERFACE + ${qt_loc}/include/QtDBus + ) + endif() + + if (Qt6WaylandClient_FOUND) + target_include_directories(external_qt SYSTEM + INTERFACE + ${qt_loc}/include/QtWaylandClient + ${qt_loc}/include/QtWaylandClient/${qt_version} + ${qt_loc}/include/QtWaylandClient/${qt_version}/QtWaylandClient + ) + endif() + + target_compile_definitions(external_qt + INTERFACE + _REENTRANT + QT_STATICPLUGIN + QT_PLUGIN + QT_SVG_LIB + QT_NETWORK_LIB + QT_OPENGLWIDGETS_LIB + QT_WIDGETS_LIB + QT_OPENGL_LIB + QT_GUI_LIB + QT_CORE5COMPAT_LIB + QT_CORE_LIB + ) + + if (Qt6DBus_FOUND) + target_compile_definitions(external_qt + INTERFACE + QT_DBUS_LIB + ) + endif() + + if (Qt6WaylandClient_FOUND) + target_compile_definitions(external_qt + INTERFACE + QT_WAYLANDCLIENT_LIB + ) + endif() + + if (WIN32) + set(qt_lib_prefix "") + set(qt_lib_suffix $<$:d>.lib) + else() + set(qt_lib_prefix lib) + if (APPLE) + set(qt_lib_suffix $<$:_debug>.a) + else() + set(qt_lib_suffix .a) + endif() + endif() + + if (LINUX) + set(qt_lib_objects objects-RelWithDebInfo) + else() + set(qt_lib_objects objects-$,Debug,RelWithDebInfo>) + endif() + + set(common_qt_libs + plugins/imageformats/${qt_lib_prefix}qwebp + plugins/imageformats/${qt_lib_prefix}qgif + plugins/imageformats/${qt_lib_prefix}qjpeg + lib/${qt_lib_prefix}Qt6Svg + lib/${qt_lib_prefix}Qt6Network + lib/${qt_lib_prefix}Qt6OpenGLWidgets + lib/${qt_lib_prefix}Qt6Widgets + lib/${qt_lib_prefix}Qt6OpenGL + lib/${qt_lib_prefix}Qt6Gui + lib/${qt_lib_prefix}Qt6Core5Compat + lib/${qt_lib_prefix}Qt6Core + lib/${qt_lib_prefix}Qt6BundledHarfbuzz + lib/${qt_lib_prefix}Qt6BundledLibpng + lib/${qt_lib_prefix}Qt6BundledPcre2 + ) + + set(qt_libs_list "") + if (WIN32) + set(qt_libs + ${common_qt_libs} + lib/${qt_lib_prefix}Qt6WindowsUIAutomationSupport + lib/${qt_lib_prefix}qtmain + lib/${qt_lib_prefix}qtfreetype + plugins/platforms/${qt_lib_prefix}qwindows + ) + foreach (lib ${qt_libs}) + list(APPEND qt_libs_list "${qt_loc}/${lib}${qt_lib_suffix}") + endforeach() + + target_link_libraries(external_qt + INTERFACE + desktop-app::external_angle + ) + elseif (APPLE) + set(qt_libs + ${common_qt_libs} + lib/${qt_lib_prefix}Qt6GraphicsSupport + lib/${qt_lib_prefix}Qt6ClipboardSupport + lib/${qt_lib_prefix}qtfreetype + plugins/platforms/${qt_lib_prefix}qcocoa + ) + foreach (lib ${qt_libs}) + list(APPEND qt_libs_list "${qt_loc}/${lib}${qt_lib_suffix}") + endforeach() + else() + set(qt_libs_dbus) + set(qt_libs_dbus_plugins) + if (Qt6DBus_FOUND) + set(qt_libs_dbus + lib/${qt_lib_prefix}Qt6DBus + lib/${qt_lib_prefix}Qt6Core + ) + set(qt_libs_dbus_plugins + plugins/platforminputcontexts/${qt_lib_prefix}ibusplatforminputcontextplugin + ) + endif() + set(qt_libs_waylandclient) + set(qt_libs_waylandclient_plugins) + if (Qt6WaylandClient_FOUND) + set(qt_libs_waylandclient + lib/${qt_lib_prefix}Qt6WaylandEglClientHwIntegration + lib/${qt_lib_prefix}Qt6WaylandClient + ) + set(qt_libs_waylandclient_plugins + plugins/platforms/${qt_lib_prefix}qwayland-generic + plugins/platforms/${qt_lib_prefix}qwayland-egl + plugins/wayland-graphics-integration-client/${qt_lib_prefix}qt-plugin-wayland-egl + plugins/wayland-decoration-client/${qt_lib_prefix}bradient + ) + endif() + set(qt_libs + plugins/platforminputcontexts/${qt_lib_prefix}composeplatforminputcontextplugin + ${qt_libs_dbus_plugins} + ${qt_libs_waylandclient_plugins} + plugins/platformthemes/${qt_lib_prefix}qgtk3 + plugins/platforms/${qt_lib_prefix}qxcb + plugins/xcbglintegrations/${qt_lib_prefix}qxcb-egl-integration + plugins/xcbglintegrations/${qt_lib_prefix}qxcb-glx-integration + plugins/iconengines/${qt_lib_prefix}qsvgicon + lib/${qt_lib_prefix}Qt6XcbQpa + ${qt_libs_waylandclient} + ${common_qt_libs} + ${qt_libs_dbus} + ) + foreach (lib ${qt_libs}) + list(APPEND qt_libs_list "${qt_loc}/${lib}${qt_lib_suffix}") + endforeach() + endif() + + list(APPEND qt_libs_list + "${qt_loc}/lib/${qt_lib_objects}/Gui_resources_1/.rcc/qrc_qpdf.cpp.o" + "${qt_loc}/lib/${qt_lib_objects}/Widgets_resources_1/.rcc/qrc_qstyle.cpp.o" + "${qt_loc}/lib/${qt_lib_objects}/Widgets_resources_2/.rcc/qrc_qstyle1.cpp.o" + "${qt_loc}/lib/${qt_lib_objects}/Widgets_resources_3/.rcc/qrc_qmessagebox.cpp.o" + ) + + target_link_libraries(external_qt + INTERFACE + ${qt_libs_list} + $ + $ + desktop-app::external_jpeg + desktop-app::external_zlib + ) + + if (LINUX) + target_include_directories(external_qt SYSTEM + INTERFACE + ${qt_loc}/mkspecs/linux-g++ + ) + target_link_static_libraries(external_qt + INTERFACE + proxy + epoxy + xkbcommon + xkbcommon-x11 + xcb-glx + xcb-xkb + xcb-randr + xcb-icccm + xcb-shm + xcb-render + xcb-image + xcb-xfixes + xcb-xinput + xcb-shape + xcb-sync + xcb-util + xcb-render-util + xcb-keysyms + z + ) + if (Qt6WaylandClient_FOUND) + target_link_libraries(external_qt + INTERFACE + desktop-app::linux_wayland_helper + $ + ) + endif() + target_link_libraries(external_qt + INTERFACE + desktop-app::linux_gtk_helper + $ + desktop-app::linux_glib_helper + $ + fontconfig + freetype + xcb + X11 + X11-xcb + ${CMAKE_DL_LIBS} + pthread + ) + endif() +endif() diff --git a/external/qt/qt_static_plugins/CMakeLists.txt b/external/qt/qt_static_plugins/CMakeLists.txt index 7a8651a..5fad7e3 100644 --- a/external/qt/qt_static_plugins/CMakeLists.txt +++ b/external/qt/qt_static_plugins/CMakeLists.txt @@ -25,10 +25,12 @@ if (LINUX) ) if (NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION) - target_link_libraries(external_qt_static_plugins - PUBLIC - desktop-app::external_fcitx_qt5 - ) + if (NOT DESKTOP_APP_QT6) + target_link_libraries(external_qt_static_plugins + PUBLIC + desktop-app::external_fcitx_qt5 + ) + endif() if (NOT DESKTOP_APP_DISABLE_X11_INTEGRATION) target_link_libraries(external_qt_static_plugins @@ -38,7 +40,7 @@ if (LINUX) endif() endif() - if (NOT DESKTOP_APP_DISABLE_X11_INTEGRATION) + if (NOT DESKTOP_APP_DISABLE_X11_INTEGRATION AND NOT DESKTOP_APP_QT6) target_link_libraries(external_qt_static_plugins PUBLIC desktop-app::external_hime_qt diff --git a/external/qt/qt_static_plugins/qt_static_plugins.cpp b/external/qt/qt_static_plugins/qt_static_plugins.cpp index 25fc093..f876501 100644 --- a/external/qt/qt_static_plugins/qt_static_plugins.cpp +++ b/external/qt/qt_static_plugins/qt_static_plugins.cpp @@ -8,7 +8,10 @@ https://github.com/desktop-app/legal/blob/master/LEGAL #include #ifndef DESKTOP_APP_USE_PACKAGED +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) Q_IMPORT_PLUGIN(QGenericEnginePlugin) +#endif // Qt < 6.0.0 + Q_IMPORT_PLUGIN(QWebpPlugin) Q_IMPORT_PLUGIN(QJpegPlugin) Q_IMPORT_PLUGIN(QGifPlugin) @@ -24,8 +27,10 @@ Q_IMPORT_PLUGIN(QXcbGlxIntegrationPlugin) Q_IMPORT_PLUGIN(QComposePlatformInputContextPlugin) Q_IMPORT_PLUGIN(QSvgIconPlugin) #ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) Q_IMPORT_PLUGIN(QConnmanEnginePlugin) Q_IMPORT_PLUGIN(QNetworkManagerEnginePlugin) +#endif // Qt < 6.0.0 Q_IMPORT_PLUGIN(QIbusPlatformInputContextPlugin) #endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION #ifndef DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION @@ -42,13 +47,17 @@ Q_IMPORT_PLUGIN(QGtk3ThemePlugin) #if !defined DESKTOP_APP_USE_PACKAGED || defined DESKTOP_APP_USE_PACKAGED_LAZY Q_IMPORT_PLUGIN(NimfInputContextPlugin) #ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) Q_IMPORT_PLUGIN(QFcitxPlatformInputContextPlugin) +#endif // Qt < 6.0.0 #ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION Q_IMPORT_PLUGIN(QFcitx5PlatformInputContextPlugin) #endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION #endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION #ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) Q_IMPORT_PLUGIN(QHimePlatformInputContextPlugin) +#endif // Qt < 6.0.0 #endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION #endif // !DESKTOP_APP_USE_PACKAGED || DESKTOP_APP_USE_PACKAGED_LAZY #endif // Q_OS_UNIX && !Q_OS_MAC diff --git a/linux_glib_helper/linux_glib_helper.cpp b/linux_glib_helper/linux_glib_helper.cpp index a6d0474..b312d83 100644 --- a/linux_glib_helper/linux_glib_helper.cpp +++ b/linux_glib_helper/linux_glib_helper.cpp @@ -29,6 +29,7 @@ guint (*g_log_set_handler)( GMainContext* (*g_main_context_default)(void); gboolean (*g_main_context_iteration)(GMainContext* context, gboolean may_block); GMainContext* (*g_main_context_new)(void); +// TODO: Remove when Qt 5 support will be dropped gboolean (*g_main_context_pending)(GMainContext* context); void (*g_main_context_pop_thread_default)(GMainContext* context); void (*g_main_context_push_thread_default)(GMainContext* context); @@ -46,6 +47,7 @@ void (*g_source_destroy)(GSource* source); GSource* (*g_source_new)(GSourceFuncs* source_funcs, guint struct_size); void (*g_source_remove_poll)(GSource* source, GPollFD* fd); void (*g_source_set_can_recurse)(GSource* source, gboolean can_recurse); +void (*g_source_set_name)(GSource* source, const char* name); void (*g_source_unref)(GSource* source); int (*g_strcmp0)(const char* str1, const char* str2); @@ -140,6 +142,7 @@ bool Resolve() { && LOAD_SYMBOL(lib, g_source_new) && LOAD_SYMBOL(lib, g_source_remove_poll) && LOAD_SYMBOL(lib, g_source_set_can_recurse) + && LOAD_SYMBOL(lib, g_source_set_name) && LOAD_SYMBOL(lib, g_source_unref) && LOAD_SYMBOL(lib, g_strcmp0) && LoadLibrary(lib, "libgobject-2.0.so.0") @@ -283,6 +286,11 @@ void g_source_set_can_recurse(GSource* source, gboolean can_recurse) { GlibHelper::g_source_set_can_recurse(source, can_recurse); } +void g_source_set_name(GSource* source, const char* name) { + GlibHelper::Resolve(); + GlibHelper::g_source_set_name(source, name); +} + void g_source_unref(GSource* source) { GlibHelper::Resolve(); GlibHelper::g_source_unref(source); diff --git a/options.cmake b/options.cmake index 91d8897..85e2f3c 100644 --- a/options.cmake +++ b/options.cmake @@ -12,6 +12,7 @@ INTERFACE $<$:_DEBUG> QT_NO_KEYWORDS QT_NO_CAST_FROM_BYTEARRAY + QT_IMPLICIT_QCHAR_CONSTRUCTION ) if (DESKTOP_APP_DISABLE_CRASH_REPORTS) diff --git a/variables.cmake b/variables.cmake index 08b5bd9..23c38b8 100644 --- a/variables.cmake +++ b/variables.cmake @@ -32,6 +32,7 @@ option(DESKTOP_APP_DISABLE_AUTOUPDATE "Disable autoupdate." ${disable_autoupdate option(DESKTOP_APP_USE_HUNSPELL_ONLY "Disable system spellchecker and use bundled Hunspell only. (For debugging purposes)" OFF) option(DESKTOP_APP_USE_ENCHANT "Use Enchant instead of bundled Hunspell. (Linux only)" OFF) option(DESKTOP_APP_NO_PDB "Disable PDB file generation. (Windows only)" OFF) +option(DESKTOP_APP_QT6 "Build with Qt 6" OFF) set(dont_bundle_fonts 0) if (DESKTOP_APP_USE_PACKAGED AND NOT DESKTOP_APP_USE_PACKAGED_LAZY) From 6ef834cf3cb9fa5e81e63a4f5cd3ba1eedbd75de Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Thu, 21 Oct 2021 08:58:28 +0400 Subject: [PATCH 11/34] Don't warn about deprecated declarations with Qt 6 --- options_linux.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/options_linux.cmake b/options_linux.cmake index 24f0e0e..0310845 100644 --- a/options_linux.cmake +++ b/options_linux.cmake @@ -36,6 +36,14 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") ) endif() +# TODO: Remove when there will be no Qt 5 support +if (DESKTOP_APP_QT6) + target_compile_options(common_options + INTERFACE + -Wno-deprecated-declarations + ) +endif() + if (DESKTOP_APP_SPECIAL_TARGET) target_compile_options(common_options INTERFACE From 993e1e052ee09e0c4ddd9df8a09746e113d1a832 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Thu, 21 Oct 2021 10:10:30 +0400 Subject: [PATCH 12/34] Add OpenSSL plugin to Qt 6 build --- external/qt/qt6/CMakeLists.txt | 1 + external/qt/qt_static_plugins/qt_static_plugins.cpp | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/external/qt/qt6/CMakeLists.txt b/external/qt/qt6/CMakeLists.txt index 8426de7..294af5c 100644 --- a/external/qt/qt6/CMakeLists.txt +++ b/external/qt/qt6/CMakeLists.txt @@ -119,6 +119,7 @@ else() endif() set(common_qt_libs + plugins/tls/${qt_lib_prefix}qopensslbackend plugins/imageformats/${qt_lib_prefix}qwebp plugins/imageformats/${qt_lib_prefix}qgif plugins/imageformats/${qt_lib_prefix}qjpeg diff --git a/external/qt/qt_static_plugins/qt_static_plugins.cpp b/external/qt/qt_static_plugins/qt_static_plugins.cpp index f876501..c1251b4 100644 --- a/external/qt/qt_static_plugins/qt_static_plugins.cpp +++ b/external/qt/qt_static_plugins/qt_static_plugins.cpp @@ -8,7 +8,9 @@ https://github.com/desktop-app/legal/blob/master/LEGAL #include #ifndef DESKTOP_APP_USE_PACKAGED -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +Q_IMPORT_PLUGIN(QTlsBackendOpenSSL) +#else // Qt >= 6.0.0 Q_IMPORT_PLUGIN(QGenericEnginePlugin) #endif // Qt < 6.0.0 From 8540bd0b6007648792e700719b291f83fc75d9da Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Thu, 21 Oct 2021 10:45:33 +0400 Subject: [PATCH 13/34] Fix static build without Wayland --- external/qt/CMakeLists.txt | 10 +++++----- external/qt/qt6/CMakeLists.txt | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/external/qt/CMakeLists.txt b/external/qt/CMakeLists.txt index f1649ad..727db1e 100644 --- a/external/qt/CMakeLists.txt +++ b/external/qt/CMakeLists.txt @@ -42,7 +42,7 @@ if (DESKTOP_APP_USE_PACKAGED) ) endif() - if (Qt5WaylandClient_FOUND) + if (NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) target_link_libraries(external_qt INTERFACE Qt5::WaylandClient) target_include_directories(external_qt SYSTEM @@ -80,7 +80,7 @@ else() ) endif() - if (Qt5WaylandClient_FOUND) + if (NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) target_include_directories(external_qt SYSTEM INTERFACE ${qt_loc}/include/QtWaylandClient @@ -115,7 +115,7 @@ else() ) endif() - if (Qt5WaylandClient_FOUND) + if (NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) target_compile_definitions(external_qt INTERFACE QT_WAYLANDCLIENT_LIB @@ -206,7 +206,7 @@ else() endif() set(qt_libs_waylandclient) set(qt_libs_waylandclient_plugins) - if (Qt5WaylandClient_FOUND) + if (NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) set(qt_libs_waylandclient lib/${qt_lib_prefix}Qt5WaylandClient) set(qt_libs_waylandclient_plugins plugins/platforms/${qt_lib_prefix}qwayland-generic @@ -281,7 +281,7 @@ else() xcb-keysyms z ) - if (Qt5WaylandClient_FOUND) + if (NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) target_link_libraries(external_qt INTERFACE desktop-app::linux_wayland_helper diff --git a/external/qt/qt6/CMakeLists.txt b/external/qt/qt6/CMakeLists.txt index 294af5c..7ac5536 100644 --- a/external/qt/qt6/CMakeLists.txt +++ b/external/qt/qt6/CMakeLists.txt @@ -30,7 +30,7 @@ if (DESKTOP_APP_USE_PACKAGED) target_link_libraries(external_qt INTERFACE Qt6::DBus) endif() - if (Qt6WaylandClient_FOUND) + if (NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) target_link_libraries(external_qt INTERFACE Qt6::WaylandClient) target_include_directories(external_qt SYSTEM @@ -62,7 +62,7 @@ else() ) endif() - if (Qt6WaylandClient_FOUND) + if (NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) target_include_directories(external_qt SYSTEM INTERFACE ${qt_loc}/include/QtWaylandClient @@ -93,7 +93,7 @@ else() ) endif() - if (Qt6WaylandClient_FOUND) + if (NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) target_compile_definitions(external_qt INTERFACE QT_WAYLANDCLIENT_LIB @@ -178,7 +178,7 @@ else() endif() set(qt_libs_waylandclient) set(qt_libs_waylandclient_plugins) - if (Qt6WaylandClient_FOUND) + if (NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) set(qt_libs_waylandclient lib/${qt_lib_prefix}Qt6WaylandEglClientHwIntegration lib/${qt_lib_prefix}Qt6WaylandClient @@ -252,7 +252,7 @@ else() xcb-keysyms z ) - if (Qt6WaylandClient_FOUND) + if (NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) target_link_libraries(external_qt INTERFACE desktop-app::linux_wayland_helper From 02993a6c82c6a31f223a9a07eaba6c7c276ffa67 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Thu, 21 Oct 2021 16:57:30 +0400 Subject: [PATCH 14/34] Add missed LINUX condition --- external/qt/CMakeLists.txt | 6 +++--- external/qt/qt6/CMakeLists.txt | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/external/qt/CMakeLists.txt b/external/qt/CMakeLists.txt index 727db1e..0633ebb 100644 --- a/external/qt/CMakeLists.txt +++ b/external/qt/CMakeLists.txt @@ -42,7 +42,7 @@ if (DESKTOP_APP_USE_PACKAGED) ) endif() - if (NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) + if (LINUX AND NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) target_link_libraries(external_qt INTERFACE Qt5::WaylandClient) target_include_directories(external_qt SYSTEM @@ -80,7 +80,7 @@ else() ) endif() - if (NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) + if (LINUX AND NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) target_include_directories(external_qt SYSTEM INTERFACE ${qt_loc}/include/QtWaylandClient @@ -115,7 +115,7 @@ else() ) endif() - if (NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) + if (LINUX AND NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) target_compile_definitions(external_qt INTERFACE QT_WAYLANDCLIENT_LIB diff --git a/external/qt/qt6/CMakeLists.txt b/external/qt/qt6/CMakeLists.txt index 7ac5536..b397ff6 100644 --- a/external/qt/qt6/CMakeLists.txt +++ b/external/qt/qt6/CMakeLists.txt @@ -30,7 +30,7 @@ if (DESKTOP_APP_USE_PACKAGED) target_link_libraries(external_qt INTERFACE Qt6::DBus) endif() - if (NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) + if (LINUX AND NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) target_link_libraries(external_qt INTERFACE Qt6::WaylandClient) target_include_directories(external_qt SYSTEM @@ -62,7 +62,7 @@ else() ) endif() - if (NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) + if (LINUX AND NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) target_include_directories(external_qt SYSTEM INTERFACE ${qt_loc}/include/QtWaylandClient @@ -93,7 +93,7 @@ else() ) endif() - if (NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) + if (LINUX AND NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) target_compile_definitions(external_qt INTERFACE QT_WAYLANDCLIENT_LIB From 57ccb6c03c1ff68d294f61e539c34ffbdcc39531 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 21 Oct 2021 19:45:43 +0400 Subject: [PATCH 15/34] Fix build with Qt 6.2 on macOS. --- external/qt/qt6/CMakeLists.txt | 13 ++++++++----- external/qt/qt_static_plugins/qt_static_plugins.cpp | 6 ++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/external/qt/qt6/CMakeLists.txt b/external/qt/qt6/CMakeLists.txt index b397ff6..b1a2910 100644 --- a/external/qt/qt6/CMakeLists.txt +++ b/external/qt/qt6/CMakeLists.txt @@ -119,7 +119,6 @@ else() endif() set(common_qt_libs - plugins/tls/${qt_lib_prefix}qopensslbackend plugins/imageformats/${qt_lib_prefix}qwebp plugins/imageformats/${qt_lib_prefix}qgif plugins/imageformats/${qt_lib_prefix}qjpeg @@ -142,8 +141,9 @@ else() ${common_qt_libs} lib/${qt_lib_prefix}Qt6WindowsUIAutomationSupport lib/${qt_lib_prefix}qtmain - lib/${qt_lib_prefix}qtfreetype + lib/${qt_lib_prefix}Qt6BundledFreetype plugins/platforms/${qt_lib_prefix}qwindows + plugins/tls/${qt_lib_prefix}qopensslbackend ) foreach (lib ${qt_libs}) list(APPEND qt_libs_list "${qt_loc}/${lib}${qt_lib_suffix}") @@ -156,14 +156,16 @@ else() elseif (APPLE) set(qt_libs ${common_qt_libs} - lib/${qt_lib_prefix}Qt6GraphicsSupport - lib/${qt_lib_prefix}Qt6ClipboardSupport - lib/${qt_lib_prefix}qtfreetype + lib/${qt_lib_prefix}Qt6BundledFreetype plugins/platforms/${qt_lib_prefix}qcocoa + plugins/tls/${qt_lib_prefix}qsecuretransportbackend ) foreach (lib ${qt_libs}) list(APPEND qt_libs_list "${qt_loc}/${lib}${qt_lib_suffix}") endforeach() + list(APPEND qt_libs_list + "${qt_loc}/lib/${qt_lib_objects}/QCocoaIntegrationPlugin_resources_1/.rcc/qrc_qcocoaresources.cpp.o" + ) else() set(qt_libs_dbus) set(qt_libs_dbus_plugins) @@ -196,6 +198,7 @@ else() ${qt_libs_waylandclient_plugins} plugins/platformthemes/${qt_lib_prefix}qgtk3 plugins/platforms/${qt_lib_prefix}qxcb + plugins/tls/${qt_lib_prefix}qopensslbackend plugins/xcbglintegrations/${qt_lib_prefix}qxcb-egl-integration plugins/xcbglintegrations/${qt_lib_prefix}qxcb-glx-integration plugins/iconengines/${qt_lib_prefix}qsvgicon diff --git a/external/qt/qt_static_plugins/qt_static_plugins.cpp b/external/qt/qt_static_plugins/qt_static_plugins.cpp index c1251b4..d10f99b 100644 --- a/external/qt/qt_static_plugins/qt_static_plugins.cpp +++ b/external/qt/qt_static_plugins/qt_static_plugins.cpp @@ -9,7 +9,13 @@ https://github.com/desktop-app/legal/blob/master/LEGAL #ifndef DESKTOP_APP_USE_PACKAGED #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + +#ifdef Q_OS_MAC +Q_IMPORT_PLUGIN(QSecureTransportBackend) +#else // Q_OS_MAC Q_IMPORT_PLUGIN(QTlsBackendOpenSSL) +#endif // Q_OS_MAC + #else // Qt >= 6.0.0 Q_IMPORT_PLUGIN(QGenericEnginePlugin) #endif // Qt < 6.0.0 From 50745176b15d9f19ae41b4f372dd1ada7bce6baf Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sun, 24 Oct 2021 04:29:11 +0400 Subject: [PATCH 16/34] Enable dbusmenu-qt with Qt 6 --- external/CMakeLists.txt | 4 ++-- external/dbusmenu_qt/CMakeLists.txt | 20 ++++++++++++++------ external/statusnotifieritem/CMakeLists.txt | 18 +++++++++++++----- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 633ceb5..8b5ce46 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -14,7 +14,7 @@ endmacro() add_checked_subdirectory(angle) add_checked_subdirectory(auto_updates) add_checked_subdirectory(crash_reports) -if (LINUX AND NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION AND NOT DESKTOP_APP_QT6) +if (LINUX AND NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION) add_checked_subdirectory(dbusmenu_qt) endif() add_checked_subdirectory(expected) @@ -59,7 +59,7 @@ add_checked_subdirectory(qr_code_generator) add_checked_subdirectory(ranges) add_checked_subdirectory(rlottie) add_checked_subdirectory(rnnoise) -if (LINUX AND NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION AND NOT DESKTOP_APP_QT6) +if (LINUX AND NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION) add_checked_subdirectory(statusnotifieritem) endif() add_checked_subdirectory(ton) diff --git a/external/dbusmenu_qt/CMakeLists.txt b/external/dbusmenu_qt/CMakeLists.txt index 3c38863..b593a58 100644 --- a/external/dbusmenu_qt/CMakeLists.txt +++ b/external/dbusmenu_qt/CMakeLists.txt @@ -7,7 +7,7 @@ add_library(external_dbusmenu_qt INTERFACE IMPORTED GLOBAL) add_library(desktop-app::external_dbusmenu_qt ALIAS external_dbusmenu_qt) -if (DESKTOP_APP_USE_PACKAGED) +if (DESKTOP_APP_USE_PACKAGED AND NOT DESKTOP_APP_QT6) if (DESKTOP_APP_USE_PACKAGED_LAZY) find_package(dbusmenu-qt5 QUIET) else() @@ -48,11 +48,19 @@ if (NOT dbusmenu-qt5_FOUND) utils.cpp ) - qt5_add_dbus_adaptor(dbusmenu_adaptor - ${dbusmenu_qt_loc}/com.canonical.dbusmenu.xml - ${dbusmenu_qt_loc}/dbusmenuexporterdbus_p.h - DBusMenuExporterDBus - ) + if (DESKTOP_APP_QT6) + qt6_add_dbus_adaptor(dbusmenu_adaptor + ${dbusmenu_qt_loc}/com.canonical.dbusmenu.xml + ${dbusmenu_qt_loc}/dbusmenuexporterdbus_p.h + DBusMenuExporterDBus + ) + else() + qt5_add_dbus_adaptor(dbusmenu_adaptor + ${dbusmenu_qt_loc}/com.canonical.dbusmenu.xml + ${dbusmenu_qt_loc}/dbusmenuexporterdbus_p.h + DBusMenuExporterDBus + ) + endif() target_sources(external_dbusmenu_qt_bundled PRIVATE ${dbusmenu_adaptor}) diff --git a/external/statusnotifieritem/CMakeLists.txt b/external/statusnotifieritem/CMakeLists.txt index d17d5ad..f31e188 100644 --- a/external/statusnotifieritem/CMakeLists.txt +++ b/external/statusnotifieritem/CMakeLists.txt @@ -18,11 +18,19 @@ PRIVATE statusnotifieritem.h ) -qt5_add_dbus_adaptor(sni_adaptor - ${statusnotifieritem_loc}/org.kde.StatusNotifierItem.xml - ${statusnotifieritem_loc}/statusnotifieritem.h - StatusNotifierItem -) +if (DESKTOP_APP_QT6) + qt6_add_dbus_adaptor(sni_adaptor + ${statusnotifieritem_loc}/org.kde.StatusNotifierItem.xml + ${statusnotifieritem_loc}/statusnotifieritem.h + StatusNotifierItem + ) +else() + qt5_add_dbus_adaptor(sni_adaptor + ${statusnotifieritem_loc}/org.kde.StatusNotifierItem.xml + ${statusnotifieritem_loc}/statusnotifieritem.h + StatusNotifierItem + ) +endif() set_target_properties(external_statusnotifieritem PROPERTIES AUTOMOC ON) From 5ff43f9c518c089b21907780c00470e741a2cdb8 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sun, 24 Oct 2021 13:46:48 +0400 Subject: [PATCH 17/34] Enable HIME with Qt 6 --- external/CMakeLists.txt | 2 +- external/qt/qt_static_plugins/CMakeLists.txt | 2 +- external/qt/qt_static_plugins/qt_static_plugins.cpp | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 8b5ce46..4609b1f 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -32,7 +32,7 @@ if (LINUX AND NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION) add_checked_subdirectory(glibmm) endif() add_checked_subdirectory(gsl) -if (LINUX AND NOT DESKTOP_APP_DISABLE_X11_INTEGRATION AND NOT DESKTOP_APP_QT6) +if (LINUX AND NOT DESKTOP_APP_DISABLE_X11_INTEGRATION) add_checked_subdirectory(hime_qt) endif() if (add_hunspell_library) diff --git a/external/qt/qt_static_plugins/CMakeLists.txt b/external/qt/qt_static_plugins/CMakeLists.txt index 5fad7e3..e6668af 100644 --- a/external/qt/qt_static_plugins/CMakeLists.txt +++ b/external/qt/qt_static_plugins/CMakeLists.txt @@ -40,7 +40,7 @@ if (LINUX) endif() endif() - if (NOT DESKTOP_APP_DISABLE_X11_INTEGRATION AND NOT DESKTOP_APP_QT6) + if (NOT DESKTOP_APP_DISABLE_X11_INTEGRATION) target_link_libraries(external_qt_static_plugins PUBLIC desktop-app::external_hime_qt diff --git a/external/qt/qt_static_plugins/qt_static_plugins.cpp b/external/qt/qt_static_plugins/qt_static_plugins.cpp index d10f99b..de7e757 100644 --- a/external/qt/qt_static_plugins/qt_static_plugins.cpp +++ b/external/qt/qt_static_plugins/qt_static_plugins.cpp @@ -63,9 +63,7 @@ Q_IMPORT_PLUGIN(QFcitx5PlatformInputContextPlugin) #endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION #endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION #ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) Q_IMPORT_PLUGIN(QHimePlatformInputContextPlugin) -#endif // Qt < 6.0.0 #endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION #endif // !DESKTOP_APP_USE_PACKAGED || DESKTOP_APP_USE_PACKAGED_LAZY #endif // Q_OS_UNIX && !Q_OS_MAC From 04de294533c2beac2bda8e4dbbf5dc53eac18fd9 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Mon, 25 Oct 2021 07:35:28 +0400 Subject: [PATCH 18/34] Re-enable kwayland with Qt 6 --- external/CMakeLists.txt | 2 +- external/kwayland/CMakeLists.txt | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 4609b1f..64e9c89 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -43,7 +43,7 @@ if (LINUX) add_checked_subdirectory(jemalloc) endif() add_checked_subdirectory(jpeg) -if (LINUX AND NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION AND NOT DESKTOP_APP_QT6) +if (LINUX AND NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) add_checked_subdirectory(kwayland) endif() add_checked_subdirectory(lz4) diff --git a/external/kwayland/CMakeLists.txt b/external/kwayland/CMakeLists.txt index 2e908be..c6bff7b 100644 --- a/external/kwayland/CMakeLists.txt +++ b/external/kwayland/CMakeLists.txt @@ -25,11 +25,17 @@ else() /usr/local/include/KF5/KWayland/Client ) + if (DESKTOP_APP_QT6) + set(qtconcurrent_loc ${qt_loc}/lib/libQt6Concurrent.a) + else() + set(qtconcurrent_loc ${qt_loc}/lib/libQt5Concurrent.a) + endif() + target_link_libraries(external_kwayland INTERFACE desktop-app::linux_wayland_helper $ - ${qt_loc}/lib/libQt5Concurrent.a + ${qtconcurrent_loc} desktop-app::external_qt ) endif() From 891798c735fd9fce4c40f6fdf4adf00322119938 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 25 Oct 2021 12:43:42 +0400 Subject: [PATCH 19/34] Enable universal binaries build on macOS with Qt 6.2. --- validate_special_target.cmake | 9 ++++++--- variables.cmake | 1 - 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/validate_special_target.cmake b/validate_special_target.cmake index a00c713..638e3d7 100644 --- a/validate_special_target.cmake +++ b/validate_special_target.cmake @@ -6,16 +6,19 @@ set(DESKTOP_APP_SPECIAL_TARGET "" CACHE STRING "Use special platform target, like 'macstore' for Mac App Store.") +option(DESKTOP_APP_QT6 "Build with Qt 6" OFF) + function(report_bad_special_target) if (NOT DESKTOP_APP_SPECIAL_TARGET STREQUAL "") message(FATAL_ERROR "Bad special target '${DESKTOP_APP_SPECIAL_TARGET}'") endif() endfunction() -if (NOT DESKTOP_APP_SPECIAL_TARGET STREQUAL "osx") - set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12 CACHE STRING "Minimum OS X deployment version" FORCE) +set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12 CACHE STRING "Minimum macOS deployment version" FORCE) +if (DESKTOP_APP_QT6) + set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "Target macOS architectures" FORCE) else() - set(CMAKE_OSX_DEPLOYMENT_TARGET 10.10 CACHE STRING "Minimum OS X deployment version" FORCE) + set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "Target macOS architectures" FORCE) endif() if (WIN32) diff --git a/variables.cmake b/variables.cmake index 23c38b8..08b5bd9 100644 --- a/variables.cmake +++ b/variables.cmake @@ -32,7 +32,6 @@ option(DESKTOP_APP_DISABLE_AUTOUPDATE "Disable autoupdate." ${disable_autoupdate option(DESKTOP_APP_USE_HUNSPELL_ONLY "Disable system spellchecker and use bundled Hunspell only. (For debugging purposes)" OFF) option(DESKTOP_APP_USE_ENCHANT "Use Enchant instead of bundled Hunspell. (Linux only)" OFF) option(DESKTOP_APP_NO_PDB "Disable PDB file generation. (Windows only)" OFF) -option(DESKTOP_APP_QT6 "Build with Qt 6" OFF) set(dont_bundle_fonts 0) if (DESKTOP_APP_USE_PACKAGED AND NOT DESKTOP_APP_USE_PACKAGED_LAZY) From 971973d7da96e8a32f45cfdde62357b43ba5f577 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 25 Oct 2021 23:12:56 +0400 Subject: [PATCH 20/34] Fix warning in linking with FFMpeg. --- options_mac.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/options_mac.cmake b/options_mac.cmake index 80ffb3d..c7792c7 100644 --- a/options_mac.cmake +++ b/options_mac.cmake @@ -47,6 +47,11 @@ if (DESKTOP_APP_SPECIAL_TARGET) ) endif() +target_link_options(common_options +INTERFACE + -Wl,-no_compact_unwind +) + target_link_frameworks(common_options INTERFACE Cocoa From b1d90c34ffe36c63234c48ef8ed66cfb0bc881ea Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 25 Oct 2021 23:13:17 +0400 Subject: [PATCH 21/34] Update crashpad to a build from a fork. --- external/crash_reports/crashpad/CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/external/crash_reports/crashpad/CMakeLists.txt b/external/crash_reports/crashpad/CMakeLists.txt index 93aecba..8c47b6c 100644 --- a/external/crash_reports/crashpad/CMakeLists.txt +++ b/external/crash_reports/crashpad/CMakeLists.txt @@ -10,14 +10,15 @@ add_library(desktop-app::external_crashpad ALIAS external_crashpad) target_include_directories(external_crashpad SYSTEM INTERFACE ${libs_loc}/crashpad - ${libs_loc}/crashpad/third_party/mini_chromium/mini_chromium + ${libs_loc}/crashpad/gen + ${libs_loc}/crashpad/third_party/mini_chromium ) set(crashpad_lib_loc ${libs_loc}/crashpad/out/$,Debug,Release>) target_link_libraries(external_crashpad INTERFACE - ${crashpad_lib_loc}/libbase.a + ${crashpad_lib_loc}/libmini_chromium_base.a ${crashpad_lib_loc}/libcrashpad_client.a ${crashpad_lib_loc}/libcrashpad_util.a bsm From 33799d3d6c6cc6634f8e69406ce132bb65ebc3b7 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 26 Oct 2021 16:32:47 +0400 Subject: [PATCH 22/34] Disable ARM NEON in bundled rlottie. The ARM NEON assembler file from pixman doesn't build on macOS with "-arch arm64". --- external/rlottie/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/external/rlottie/CMakeLists.txt b/external/rlottie/CMakeLists.txt index e19cbe2..dd87a7d 100644 --- a/external/rlottie/CMakeLists.txt +++ b/external/rlottie/CMakeLists.txt @@ -119,6 +119,7 @@ else() PRIVATE _USE_MATH_DEFINES "RAPIDJSON_ASSERT=(void)" + LOTTIE_DISABLE_ARM_NEON ) target_include_directories(external_rlottie_bundled From c0c09baa3563980602ab98dcc21fe1d1b58ee4a8 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 27 Oct 2021 10:37:14 +0400 Subject: [PATCH 23/34] Accept CMAKE_OSX_ARCHITECTURES from command line. --- run_cmake.py | 2 +- validate_special_target.cmake | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/run_cmake.py b/run_cmake.py index ca0ad66..c73495f 100644 --- a/run_cmake.py +++ b/run_cmake.py @@ -44,7 +44,7 @@ def run(project, arguments, buildType=''): cmake.append('-DDESKTOP_APP_SPECIAL_TARGET=' + target) cmake.extend(['-Werror=dev', '-Werror=deprecated', '--warn-uninitialized', '..' if not buildType else '../..']) - command = ' '.join(cmake) + command = '"' + '" "'.join(cmake) + '"' if not os.path.exists(basePath): os.makedirs(basePath) diff --git a/validate_special_target.cmake b/validate_special_target.cmake index 638e3d7..f527262 100644 --- a/validate_special_target.cmake +++ b/validate_special_target.cmake @@ -15,9 +15,7 @@ function(report_bad_special_target) endfunction() set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12 CACHE STRING "Minimum macOS deployment version" FORCE) -if (DESKTOP_APP_QT6) - set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "Target macOS architectures" FORCE) -else() +if (NOT DESKTOP_APP_QT6) set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "Target macOS architectures" FORCE) endif() From 16224afddd0fef0cd226a531582f5dda108aa9d4 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 27 Oct 2021 14:08:05 +0400 Subject: [PATCH 24/34] Link a single crashpad_client library. --- external/crash_reports/crashpad/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/external/crash_reports/crashpad/CMakeLists.txt b/external/crash_reports/crashpad/CMakeLists.txt index 8c47b6c..9a2a783 100644 --- a/external/crash_reports/crashpad/CMakeLists.txt +++ b/external/crash_reports/crashpad/CMakeLists.txt @@ -18,8 +18,6 @@ set(crashpad_lib_loc ${libs_loc}/crashpad/out/$,Debug,Release target_link_libraries(external_crashpad INTERFACE - ${crashpad_lib_loc}/libmini_chromium_base.a ${crashpad_lib_loc}/libcrashpad_client.a - ${crashpad_lib_loc}/libcrashpad_util.a bsm ) From faf815fee0da46e8df09cd81cbfaa7bc30f842aa Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 27 Oct 2021 20:39:39 +0400 Subject: [PATCH 25/34] Allow loading Qt resources from a file on macOS. --- target_prepare_qrc.cmake | 49 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 target_prepare_qrc.cmake diff --git a/target_prepare_qrc.cmake b/target_prepare_qrc.cmake new file mode 100644 index 0000000..0e2ec4b --- /dev/null +++ b/target_prepare_qrc.cmake @@ -0,0 +1,49 @@ +# This file is part of Desktop App Toolkit, +# a set of libraries for developing nice desktop applications. +# +# For license and copyright information please follow this link: +# https://github.com/desktop-app/legal/blob/master/LEGAL + +function(target_add_resource target_name) + set(list ${ARGV}) + list(REMOVE_AT list 0) + target_sources(${target_name} PRIVATE ${list}) + get_target_property(existing_resources ${target_name} RESOURCE) + if (NOT "${existing_resources}" STREQUAL "existing_resources-NOTFOUND") + foreach(existing ${existing_resources}) + list(APPEND list ${existing}) + endforeach() + endif() + set_target_properties(${target_name} PROPERTIES RESOURCE "${list}") +endfunction() + +function(target_prepare_qrc target_name) + if (NOT APPLE) + set_target_properties(${target_name} PROPERTIES AUTORCC ON) + else() + set(rcc_flags --binary "$") + + set(qrc_files_all "$,INCLUDE,\\.qrc$>") + if (WIN32) + set(qrc_files "$") + elseif (APPLE) + set(qrc_files "$") + elseif (LINUX) + set(qrc_files "$") + endif() + set(rcc_file ${target_name}.rcc) + set(rcc_path "${CMAKE_BINARY_DIR}/${rcc_file}") + source_group(TREE ${CMAKE_BINARY_DIR} PREFIX Resources FILES ${rcc_path}) + if (DESKTOP_APP_QT6) + set(rcc_binary Qt6::rcc) + else() + set(rcc_binary Qt5::rcc) + endif() + add_custom_command(OUTPUT ${rcc_path} + DEPENDS ${qrc_files} + COMMAND ${rcc_binary} ${rcc_flags} -o ${rcc_path} ${qrc_files} + COMMAND_EXPAND_LISTS VERBATIM + ) + target_add_resource(${target_name} ${rcc_path}) + endif() +endfunction() From 68251bb2f0c132c4f16f5df4a0431452d0222b72 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Wed, 27 Oct 2021 20:21:43 +0400 Subject: [PATCH 26/34] Re-enable fcitx-qt5 with Qt 6 --- external/CMakeLists.txt | 4 +--- external/fcitx5_qt/CMakeLists.txt | 7 +----- external/fcitx_qt5/CMakeLists.txt | 22 ++++++++++++++----- external/qt/qt_static_plugins/CMakeLists.txt | 10 ++++----- .../qt_static_plugins/qt_static_plugins.cpp | 2 -- 5 files changed, 23 insertions(+), 22 deletions(-) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 64e9c89..1460cf9 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -19,9 +19,7 @@ if (LINUX AND NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION) endif() add_checked_subdirectory(expected) if (LINUX AND NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION) - if (NOT DESKTOP_APP_QT6) - add_checked_subdirectory(fcitx_qt5) - endif() + add_checked_subdirectory(fcitx_qt5) if (NOT DESKTOP_APP_DISABLE_X11_INTEGRATION) add_checked_subdirectory(fcitx5_qt) endif() diff --git a/external/fcitx5_qt/CMakeLists.txt b/external/fcitx5_qt/CMakeLists.txt index cc3ead4..b8b4c67 100644 --- a/external/fcitx5_qt/CMakeLists.txt +++ b/external/fcitx5_qt/CMakeLists.txt @@ -21,12 +21,7 @@ else() endif() set_target_properties(external_fcitx5_qt PROPERTIES AUTOMOC ON) - - if (DESKTOP_APP_QT6) - set(FCITX5_QT_EXTRA_PLUGIN_NAME "\"fcitx\",") - else() - set(FCITX5_QT_EXTRA_PLUGIN_NAME "") - endif() + set(FCITX5_QT_EXTRA_PLUGIN_NAME "") configure_file("${fcitx5_qt_src}/fcitx5.json.in" "${CMAKE_CURRENT_BINARY_DIR}/fcitx5.json") diff --git a/external/fcitx_qt5/CMakeLists.txt b/external/fcitx_qt5/CMakeLists.txt index d382963..f0e36cc 100644 --- a/external/fcitx_qt5/CMakeLists.txt +++ b/external/fcitx_qt5/CMakeLists.txt @@ -13,7 +13,12 @@ else() init_target(external_fcitx_qt5 "(external)") set(fcitx_qt5_loc ${third_party_loc}/fcitx-qt5) - set(fcitx_qt5_src ${fcitx_qt5_loc}/platforminputcontext) + + if (DESKTOP_APP_QT6) + set(fcitx_qt5_src ${fcitx_qt5_loc}/qt6/platforminputcontext) + else() + set(fcitx_qt5_src ${fcitx_qt5_loc}/qt5/platforminputcontext) + endif() set_target_properties(external_fcitx_qt5 PROPERTIES AUTOMOC ON) @@ -36,10 +41,17 @@ else() set_source_files_properties(${fcitx_qt5_src}/org.fcitx.Fcitx.InputMethod1.xml PROPERTIES INCLUDE ${fcitx_qt5_src}/fcitxqtdbustypes.h) - qt5_add_dbus_interface(fcitx_qt5_adaptors ${fcitx_qt5_src}/org.fcitx.Fcitx.InputContext.xml inputcontextproxy) - qt5_add_dbus_interface(fcitx_qt5_adaptors ${fcitx_qt5_src}/org.fcitx.Fcitx.InputContext1.xml inputcontext1proxy) - qt5_add_dbus_interface(fcitx_qt5_adaptors ${fcitx_qt5_src}/org.fcitx.Fcitx.InputMethod.xml inputmethodproxy) - qt5_add_dbus_interface(fcitx_qt5_adaptors ${fcitx_qt5_src}/org.fcitx.Fcitx.InputMethod1.xml inputmethod1proxy) + if (DESKTOP_APP_QT6) + qt6_add_dbus_interface(fcitx_qt5_adaptors ${fcitx_qt5_src}/org.fcitx.Fcitx.InputContext.xml inputcontextproxy) + qt6_add_dbus_interface(fcitx_qt5_adaptors ${fcitx_qt5_src}/org.fcitx.Fcitx.InputContext1.xml inputcontext1proxy) + qt6_add_dbus_interface(fcitx_qt5_adaptors ${fcitx_qt5_src}/org.fcitx.Fcitx.InputMethod.xml inputmethodproxy) + qt6_add_dbus_interface(fcitx_qt5_adaptors ${fcitx_qt5_src}/org.fcitx.Fcitx.InputMethod1.xml inputmethod1proxy) + else() + qt5_add_dbus_interface(fcitx_qt5_adaptors ${fcitx_qt5_src}/org.fcitx.Fcitx.InputContext.xml inputcontextproxy) + qt5_add_dbus_interface(fcitx_qt5_adaptors ${fcitx_qt5_src}/org.fcitx.Fcitx.InputContext1.xml inputcontext1proxy) + qt5_add_dbus_interface(fcitx_qt5_adaptors ${fcitx_qt5_src}/org.fcitx.Fcitx.InputMethod.xml inputmethodproxy) + qt5_add_dbus_interface(fcitx_qt5_adaptors ${fcitx_qt5_src}/org.fcitx.Fcitx.InputMethod1.xml inputmethod1proxy) + endif() target_sources(external_fcitx_qt5 PRIVATE ${fcitx_qt5_adaptors}) diff --git a/external/qt/qt_static_plugins/CMakeLists.txt b/external/qt/qt_static_plugins/CMakeLists.txt index e6668af..7a8651a 100644 --- a/external/qt/qt_static_plugins/CMakeLists.txt +++ b/external/qt/qt_static_plugins/CMakeLists.txt @@ -25,12 +25,10 @@ if (LINUX) ) if (NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION) - if (NOT DESKTOP_APP_QT6) - target_link_libraries(external_qt_static_plugins - PUBLIC - desktop-app::external_fcitx_qt5 - ) - endif() + target_link_libraries(external_qt_static_plugins + PUBLIC + desktop-app::external_fcitx_qt5 + ) if (NOT DESKTOP_APP_DISABLE_X11_INTEGRATION) target_link_libraries(external_qt_static_plugins diff --git a/external/qt/qt_static_plugins/qt_static_plugins.cpp b/external/qt/qt_static_plugins/qt_static_plugins.cpp index de7e757..e26f497 100644 --- a/external/qt/qt_static_plugins/qt_static_plugins.cpp +++ b/external/qt/qt_static_plugins/qt_static_plugins.cpp @@ -55,9 +55,7 @@ Q_IMPORT_PLUGIN(QGtk3ThemePlugin) #if !defined DESKTOP_APP_USE_PACKAGED || defined DESKTOP_APP_USE_PACKAGED_LAZY Q_IMPORT_PLUGIN(NimfInputContextPlugin) #ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) Q_IMPORT_PLUGIN(QFcitxPlatformInputContextPlugin) -#endif // Qt < 6.0.0 #ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION Q_IMPORT_PLUGIN(QFcitx5PlatformInputContextPlugin) #endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION From 410223b538e2d49d0b911648694ac878fd0596f9 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 28 Oct 2021 16:15:30 +0400 Subject: [PATCH 27/34] Add DESKTOP_APP_MAC_ARCH for separate macOS builds. --- init_target.cmake | 8 ++++++++ validate_special_target.cmake | 4 +++- variables.cmake | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/init_target.cmake b/init_target.cmake index 4e9b4c7..415d151 100644 --- a/init_target.cmake +++ b/init_target.cmake @@ -53,3 +53,11 @@ function(init_target target_name) # init_target(my_target folder_name) ) endif() endfunction() + +# This code is not supposed to run on build machine, only on target machine. +function(init_non_host_target target_name) + init_target(${target_name}) + set_target_properties(${target_name} PROPERTIES + OSX_ARCHITECTURES "${DESKTOP_APP_MAC_ARCH}" + ) +endfunction() diff --git a/validate_special_target.cmake b/validate_special_target.cmake index f527262..638e3d7 100644 --- a/validate_special_target.cmake +++ b/validate_special_target.cmake @@ -15,7 +15,9 @@ function(report_bad_special_target) endfunction() set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12 CACHE STRING "Minimum macOS deployment version" FORCE) -if (NOT DESKTOP_APP_QT6) +if (DESKTOP_APP_QT6) + set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "Target macOS architectures" FORCE) +else() set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "Target macOS architectures" FORCE) endif() diff --git a/variables.cmake b/variables.cmake index 08b5bd9..98b3895 100644 --- a/variables.cmake +++ b/variables.cmake @@ -32,6 +32,7 @@ option(DESKTOP_APP_DISABLE_AUTOUPDATE "Disable autoupdate." ${disable_autoupdate option(DESKTOP_APP_USE_HUNSPELL_ONLY "Disable system spellchecker and use bundled Hunspell only. (For debugging purposes)" OFF) option(DESKTOP_APP_USE_ENCHANT "Use Enchant instead of bundled Hunspell. (Linux only)" OFF) option(DESKTOP_APP_NO_PDB "Disable PDB file generation. (Windows only)" OFF) +set(DESKTOP_APP_MAC_ARCH "x86_64;arm64" CACHE STRING "Target macOS arch. (macOS only)") set(dont_bundle_fonts 0) if (DESKTOP_APP_USE_PACKAGED AND NOT DESKTOP_APP_USE_PACKAGED_LAZY) From 62f37fd1f68aece06470305d91afce7056aebc7c Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 29 Oct 2021 21:41:51 +0400 Subject: [PATCH 28/34] Build with Qt 6 by default on Unix systems. --- validate_special_target.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validate_special_target.cmake b/validate_special_target.cmake index 638e3d7..ae22295 100644 --- a/validate_special_target.cmake +++ b/validate_special_target.cmake @@ -6,7 +6,7 @@ set(DESKTOP_APP_SPECIAL_TARGET "" CACHE STRING "Use special platform target, like 'macstore' for Mac App Store.") -option(DESKTOP_APP_QT6 "Build with Qt 6" OFF) +option(DESKTOP_APP_QT6 "Build with Qt 6" ${UNIX}) function(report_bad_special_target) if (NOT DESKTOP_APP_SPECIAL_TARGET STREQUAL "") From a976e43aab70508a276b42c035aef730380d2be8 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sat, 30 Oct 2021 15:03:25 +0400 Subject: [PATCH 29/34] Fix CMake warning on Windows. --- validate_special_target.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/validate_special_target.cmake b/validate_special_target.cmake index ae22295..9e79684 100644 --- a/validate_special_target.cmake +++ b/validate_special_target.cmake @@ -6,7 +6,11 @@ set(DESKTOP_APP_SPECIAL_TARGET "" CACHE STRING "Use special platform target, like 'macstore' for Mac App Store.") -option(DESKTOP_APP_QT6 "Build with Qt 6" ${UNIX}) +set(default_to_qt6 1) +if (WIN32) + set(default_to_qt6 0) +endif() +option(DESKTOP_APP_QT6 "Build with Qt 6" ${default_to_qt6}) function(report_bad_special_target) if (NOT DESKTOP_APP_SPECIAL_TARGET STREQUAL "") From 13331633e5c2db1eeae045dd44de4f3ac7bdea3d Mon Sep 17 00:00:00 2001 From: John Preston Date: Sun, 31 Oct 2021 16:49:13 +0400 Subject: [PATCH 30/34] Re-enable -pie. --- options_linux.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/options_linux.cmake b/options_linux.cmake index 0310845..5ef401a 100644 --- a/options_linux.cmake +++ b/options_linux.cmake @@ -112,7 +112,7 @@ if (NOT DESKTOP_APP_USE_PACKAGED) -rdynamic -fwhole-program -Wl,-z,relro - # -pie # https://gitlab.gnome.org/GNOME/nautilus/-/issues/1601 + -pie ) endif() From d5237e224eee40dc5dd323f3f1d751c40368cb01 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Mon, 1 Nov 2021 04:08:01 +0400 Subject: [PATCH 31/34] Make -Wl,-z,now work on older systems --- CMakeLists.txt | 3 ++ external/qt/CMakeLists.txt | 2 + external/qt/qt6/CMakeLists.txt | 2 + linux_xcb_helper/CMakeLists.txt | 19 ++++++++++ linux_xcb_helper/linux_xcb_helper.cpp | 53 +++++++++++++++++++++++++++ options_linux.cmake | 1 + 6 files changed, 80 insertions(+) create mode 100644 linux_xcb_helper/CMakeLists.txt create mode 100644 linux_xcb_helper/linux_xcb_helper.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 95b0f6b..0b7cd88 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,9 @@ # https://github.com/desktop-app/legal/blob/master/LEGAL add_subdirectory(external) +if (LINUX AND NOT DESKTOP_APP_USE_PACKAGED) + add_subdirectory(linux_xcb_helper) +endif() if (LINUX AND NOT DESKTOP_APP_USE_PACKAGED AND NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) diff --git a/external/qt/CMakeLists.txt b/external/qt/CMakeLists.txt index 0633ebb..96dba52 100644 --- a/external/qt/CMakeLists.txt +++ b/external/qt/CMakeLists.txt @@ -290,6 +290,8 @@ else() endif() target_link_libraries(external_qt INTERFACE + desktop-app::linux_xcb_helper + $ desktop-app::linux_gtk_helper $ desktop-app::linux_glib_helper diff --git a/external/qt/qt6/CMakeLists.txt b/external/qt/qt6/CMakeLists.txt index b1a2910..8e55268 100644 --- a/external/qt/qt6/CMakeLists.txt +++ b/external/qt/qt6/CMakeLists.txt @@ -264,6 +264,8 @@ else() endif() target_link_libraries(external_qt INTERFACE + desktop-app::linux_xcb_helper + $ desktop-app::linux_gtk_helper $ desktop-app::linux_glib_helper diff --git a/linux_xcb_helper/CMakeLists.txt b/linux_xcb_helper/CMakeLists.txt new file mode 100644 index 0000000..f1f46c2 --- /dev/null +++ b/linux_xcb_helper/CMakeLists.txt @@ -0,0 +1,19 @@ +# This file is part of Desktop App Toolkit, +# a set of libraries for developing nice desktop applications. +# +# For license and copyright information please follow this link: +# https://github.com/desktop-app/legal/blob/master/LEGAL + +add_library(linux_xcb_helper STATIC) +init_target(linux_xcb_helper "(external)") +add_library(desktop-app::linux_xcb_helper ALIAS linux_xcb_helper) + +nice_target_sources(linux_xcb_helper ${CMAKE_CURRENT_SOURCE_DIR} +PRIVATE + linux_xcb_helper.cpp +) + +target_link_libraries(linux_xcb_helper +PUBLIC + ${CMAKE_DL_LIBS} +) diff --git a/linux_xcb_helper/linux_xcb_helper.cpp b/linux_xcb_helper/linux_xcb_helper.cpp new file mode 100644 index 0000000..e056830 --- /dev/null +++ b/linux_xcb_helper/linux_xcb_helper.cpp @@ -0,0 +1,53 @@ +// This file is part of Desktop App Toolkit, +// a set of libraries for developing nice desktop applications. +// +// For license and copyright information please follow this link: +// https://github.com/desktop-app/legal/blob/master/LEGAL +// +#include +#include +#include +#include + +unsigned int xcb_send_request_with_fds( + xcb_connection_t *c, + int flags, + struct iovec *vector, + const xcb_protocol_request_t *req, + unsigned int num_fds, + int *fds) { + const auto send_request_with_fds = reinterpret_cast(dlsym(RTLD_NEXT, "xcb_send_request_with_fds")); + + if (!dlerror()) { + return send_request_with_fds(c, flags, vector, req, num_fds, fds); + } + + const auto send_fd = reinterpret_cast( + dlsym(RTLD_NEXT, "xcb_send_fd")); + + if (dlerror()) { + abort(); + } + + const auto send_request = reinterpret_cast(dlsym(RTLD_NEXT, "xcb_send_request")); + + if (dlerror()) { + abort(); + } + + for (int i = 0; i != num_fds; ++i) { + send_fd(c, fds[i]); + } + + return send_request(c, flags, vector, req); +} diff --git a/options_linux.cmake b/options_linux.cmake index 5ef401a..c3fce09 100644 --- a/options_linux.cmake +++ b/options_linux.cmake @@ -112,6 +112,7 @@ if (NOT DESKTOP_APP_USE_PACKAGED) -rdynamic -fwhole-program -Wl,-z,relro + -Wl,-z,now -pie ) endif() From 393ae95d7f538301b572739d1305b41f4a54c1a5 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 2 Nov 2021 11:15:58 +0400 Subject: [PATCH 32/34] Add network reachability plugin on macOS. --- external/qt/qt6/CMakeLists.txt | 1 + external/qt/qt_static_plugins/qt_static_plugins.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/external/qt/qt6/CMakeLists.txt b/external/qt/qt6/CMakeLists.txt index 8e55268..6c5bf8f 100644 --- a/external/qt/qt6/CMakeLists.txt +++ b/external/qt/qt6/CMakeLists.txt @@ -159,6 +159,7 @@ else() lib/${qt_lib_prefix}Qt6BundledFreetype plugins/platforms/${qt_lib_prefix}qcocoa plugins/tls/${qt_lib_prefix}qsecuretransportbackend + plugins/networkinformation/${qt_lib_prefix}qscnetworkreachability ) foreach (lib ${qt_libs}) list(APPEND qt_libs_list "${qt_loc}/${lib}${qt_lib_suffix}") diff --git a/external/qt/qt_static_plugins/qt_static_plugins.cpp b/external/qt/qt_static_plugins/qt_static_plugins.cpp index e26f497..b420a52 100644 --- a/external/qt/qt_static_plugins/qt_static_plugins.cpp +++ b/external/qt/qt_static_plugins/qt_static_plugins.cpp @@ -12,6 +12,7 @@ https://github.com/desktop-app/legal/blob/master/LEGAL #ifdef Q_OS_MAC Q_IMPORT_PLUGIN(QSecureTransportBackend) +Q_IMPORT_PLUGIN(QSCNetworkReachabilityNetworkInformationBackendFactory) #else // Q_OS_MAC Q_IMPORT_PLUGIN(QTlsBackendOpenSSL) #endif // Q_OS_MAC From fc65d3305db9c194979a44fb9b71d290b39b6f5a Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 3 Nov 2021 21:34:06 +0400 Subject: [PATCH 33/34] Revert "Re-enable -pie." This reverts commit 13331633e5c2db1eeae045dd44de4f3ac7bdea3d. AppImage hack fired back: #17183 --- options_linux.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/options_linux.cmake b/options_linux.cmake index c3fce09..436266d 100644 --- a/options_linux.cmake +++ b/options_linux.cmake @@ -113,7 +113,7 @@ if (NOT DESKTOP_APP_USE_PACKAGED) -fwhole-program -Wl,-z,relro -Wl,-z,now - -pie + # -pie # https://gitlab.gnome.org/GNOME/nautilus/-/issues/1601 ) endif() From 051f7ba4e38226797bafbd9c1ed52ef38afe28b9 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sat, 6 Nov 2021 16:22:32 +0400 Subject: [PATCH 34/34] Remove DESKTOP_APP_DISABLE_WEBKITGTK --- options.cmake | 7 ------- variables.cmake | 1 - 2 files changed, 8 deletions(-) diff --git a/options.cmake b/options.cmake index 85e2f3c..66fb670 100644 --- a/options.cmake +++ b/options.cmake @@ -57,13 +57,6 @@ if (DESKTOP_APP_USE_PACKAGED_LAZY) ) endif() -if (DESKTOP_APP_DISABLE_WEBKITGTK) - target_compile_definitions(common_options - INTERFACE - DESKTOP_APP_DISABLE_WEBKITGTK - ) -endif() - if (DESKTOP_APP_USE_PACKAGED_FONTS) target_compile_definitions(common_options INTERFACE diff --git a/variables.cmake b/variables.cmake index 98b3895..768612c 100644 --- a/variables.cmake +++ b/variables.cmake @@ -26,7 +26,6 @@ option(DESKTOP_APP_USE_PACKAGED "Find libraries using CMake instead of exact pat option(DESKTOP_APP_USE_PACKAGED_LAZY "Bundle recommended Qt plugins for self-contained packages. (Linux only)" OFF) option(DESKTOP_APP_USE_PACKAGED_FFMPEG_STATIC "Link ffmpeg statically in packaged mode." OFF) option(DESKTOP_APP_DISABLE_SPELLCHECK "Disable spellcheck library." OFF) -option(DESKTOP_APP_DISABLE_WEBKITGTK "Disable WebKitGTK library (Linux only)." OFF) option(DESKTOP_APP_DISABLE_CRASH_REPORTS "Disable crash report generation." ${no_special_target}) option(DESKTOP_APP_DISABLE_AUTOUPDATE "Disable autoupdate." ${disable_autoupdate}) option(DESKTOP_APP_USE_HUNSPELL_ONLY "Disable system spellchecker and use bundled Hunspell only. (For debugging purposes)" OFF)