From bb5bc0547a26137fb04b0070f49cabed3a89aedc Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Thu, 29 Feb 2024 01:30:57 -0800 Subject: [PATCH] build: add build options for all components --- CMakeLists.txt | 14 +++++++++++++- src/core/CMakeLists.txt | 2 ++ src/wayland/CMakeLists.txt | 22 ++++++++++++++-------- src/wayland/init.cpp | 5 +++++ 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index abec58b..73a91fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,15 @@ set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) option(WAYLAND "Enable wayland support" ON) +option(WAYLAND_WLR_LAYERSHELL "Support the zwlr_layer_shell_v1 wayland protocol" ON) +option(WAYLAND_SESSION_LOCK "Support the ext_session_lock_v1 wayland protocol" ON) + +message(STATUS "Quickshell configuration") +message(STATUS " Wayland: ${WAYLAND}") +if (WAYLAND) + message(STATUS " Wlroots Layershell: ${WAYLAND_WLR_LAYERSHELL}") + message(STATUS " Session Lock: ${WAYLAND_SESSION_LOCK}") +endif () add_compile_options(-Wall -Wextra) @@ -32,4 +41,7 @@ find_package(Qt6 REQUIRED COMPONENTS ${QT_FPDEPS}) qt_standard_project_setup(REQUIRES 6.6) add_subdirectory(src/core) -add_subdirectory(src/wayland) + +if (WAYLAND) + add_subdirectory(src/wayland) +endif () diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index b9f5afc..a41f52c 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -18,3 +18,5 @@ qt_add_executable(quickshell ) qt_add_qml_module(quickshell URI Quickshell) + +target_link_libraries(quickshell PRIVATE ${QT_DEPS}) diff --git a/src/wayland/CMakeLists.txt b/src/wayland/CMakeLists.txt index 60d9adb..cde289e 100644 --- a/src/wayland/CMakeLists.txt +++ b/src/wayland/CMakeLists.txt @@ -44,19 +44,25 @@ endfunction() # ----- -qt_add_library(quickshell-wayland STATIC - wlr_layershell.cpp - session_lock.cpp -) - +qt_add_library(quickshell-wayland STATIC) qt_add_qml_module(quickshell-wayland URI Quickshell.Wayland) # required to make sure the constructor is linked add_library(quickshell-wayland-init OBJECT init.cpp) -add_subdirectory(wlr_layershell) -add_subdirectory(session_lock) +if (WAYLAND_WLR_LAYERSHELL) + target_sources(quickshell-wayland PRIVATE wlr_layershell.cpp) + add_subdirectory(wlr_layershell) + target_compile_definitions(quickshell-wayland PRIVATE QS_WAYLAND_WLR_LAYERSHELL) + target_compile_definitions(quickshell-wayland-init PRIVATE QS_WAYLAND_WLR_LAYERSHELL) +endif() + +if (WAYLAND_SESSION_LOCK) + target_sources(quickshell-wayland PRIVATE session_lock.cpp) + add_subdirectory(session_lock) +endif() + target_link_libraries(quickshell-wayland PRIVATE ${QT_DEPS}) target_link_libraries(quickshell-wayland-init PRIVATE ${QT_DEPS}) -target_link_libraries(quickshell PRIVATE ${QT_DEPS} quickshell-waylandplugin quickshell-wayland-init) +target_link_libraries(quickshell PRIVATE quickshell-waylandplugin quickshell-wayland-init) diff --git a/src/wayland/init.cpp b/src/wayland/init.cpp index 6e964fa..4a70de8 100644 --- a/src/wayland/init.cpp +++ b/src/wayland/init.cpp @@ -2,7 +2,10 @@ #include #include "../core/plugin.hpp" + +#ifdef QS_WAYLAND_WLR_LAYERSHELL #include "wlr_layershell.hpp" +#endif namespace { @@ -10,6 +13,7 @@ class WaylandPlugin: public QuickshellPlugin { bool applies() override { return QGuiApplication::platformName() == "wayland"; } void registerTypes() override { +#ifdef QS_WAYLAND_WLR_LAYERSHELL qmlRegisterType("Quickshell._WaylandOverlay", 1, 0, "PanelWindow"); // If any types are defined inside a module using QML_ELEMENT then all QML_ELEMENT types @@ -29,6 +33,7 @@ class WaylandPlugin: public QuickshellPlugin { "Quickshell._WaylandOverlay", QQmlModuleImportLatest ); +#endif } };