From 3db3eeab03fe1fc6410a338c96b4939134b1eb5b Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sat, 11 Dec 2021 20:49:04 +0400 Subject: [PATCH] Build kwayland as external project --- .gitmodules | 3 ++ external/kwayland/CMakeLists.txt | 86 ++++++++++++++++++++++---------- patches | 1 + 3 files changed, 64 insertions(+), 26 deletions(-) create mode 100644 .gitmodules create mode 160000 patches diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..516b268 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "patches"] + path = patches + url = https://github.com/desktop-app/patches.git diff --git a/external/kwayland/CMakeLists.txt b/external/kwayland/CMakeLists.txt index c6bff7b..66f1cea 100644 --- a/external/kwayland/CMakeLists.txt +++ b/external/kwayland/CMakeLists.txt @@ -4,38 +4,72 @@ # For license and copyright information please follow this link: # https://github.com/desktop-app/legal/blob/master/LEGAL -if (DESKTOP_APP_USE_PACKAGED) - add_library(external_kwayland INTERFACE IMPORTED GLOBAL) - add_library(desktop-app::external_kwayland ALIAS external_kwayland) +add_library(external_kwayland INTERFACE IMPORTED GLOBAL) +add_library(desktop-app::external_kwayland ALIAS external_kwayland) - find_package(KF5Wayland REQUIRED) - target_link_libraries(external_kwayland INTERFACE KF5::WaylandClient) -else() - add_library(external_kwayland STATIC IMPORTED GLOBAL) - add_library(desktop-app::external_kwayland ALIAS external_kwayland) +if (DESKTOP_APP_USE_PACKAGED AND NOT DESKTOP_APP_QT6) + find_package(KF5Wayland) - find_library(KWAYLAND_LIBRARY libKF5WaylandClient.a) - set_target_properties(external_kwayland PROPERTIES - IMPORTED_LOCATION "${KWAYLAND_LIBRARY}" - ) - - target_include_directories(external_kwayland SYSTEM - INTERFACE - /usr/local/include/KF5 - /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) + if (KF5Wayland_FOUND) + target_link_libraries(external_kwayland INTERFACE KF5::WaylandClient) + return() endif() +endif() - target_link_libraries(external_kwayland +add_library(external_kwayland_bundled STATIC IMPORTED) +set(kwayland_loc ${third_party_loc}/kwayland) + +set(kwayland_patch_command :) +if (DESKTOP_APP_QT6) + set(kwayland_patch_command patch -p1 < ${CMAKE_CURRENT_SOURCE_DIR}/../../patches/kwayland-qt6.patch) +endif() + +include(ExternalProject) +ExternalProject_Add(kwayland + SOURCE_DIR ${kwayland_loc} + CMAKE_GENERATOR Ninja + CMAKE_ARGS + -DCMAKE_BUILD_TYPE=Release + -DBUILD_SHARED_LIBS=OFF + -DBUILD_TESTING=OFF + PATCH_COMMAND ${kwayland_patch_command} + BUILD_COMMAND ${CMAKE_COMMAND} --build --target KF5WaylandClient + STEP_TARGETS build + EXCLUDE_FROM_ALL TRUE + BUILD_BYPRODUCTS /lib/libKF5WaylandClient.a +) + +ExternalProject_Get_property(kwayland BINARY_DIR) +set_target_properties(external_kwayland_bundled PROPERTIES + IMPORTED_LOCATION "${BINARY_DIR}/lib/libKF5WaylandClient.a" +) + +target_include_directories(external_kwayland_bundled SYSTEM +INTERFACE + ${kwayland_loc}/src/client + ${BINARY_DIR}/src/client +) + +target_link_libraries(external_kwayland_bundled +INTERFACE + desktop-app::external_qt +) + +if (DESKTOP_APP_USE_PACKAGED) + find_package(PkgConfig REQUIRED) + pkg_check_modules(WAYLAND_CLIENT REQUIRED IMPORTED_TARGET wayland-client) + target_link_libraries(external_kwayland_bundled INTERFACE PkgConfig::WAYLAND_CLIENT) +else() + target_link_libraries(external_kwayland_bundled INTERFACE desktop-app::linux_wayland_helper $ - ${qtconcurrent_loc} - desktop-app::external_qt ) endif() + +add_dependencies(external_kwayland_bundled kwayland-build) + +target_link_libraries(external_kwayland +INTERFACE + external_kwayland_bundled +) diff --git a/patches b/patches new file mode 160000 index 0000000..83a901f --- /dev/null +++ b/patches @@ -0,0 +1 @@ +Subproject commit 83a901f499c638efa54eb88aa0a2645746acda27