From 4a6769467640bd7c82c72c39ef1765c3d5734f23 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Thu, 13 Nov 2025 11:48:30 -0500 Subject: [PATCH] build: new build option BUILD_X11 to control building of X11 backend --- CMakeLists.txt | 6 ++++ cmake/Libraries.cmake | 4 ++- doc/dev/build.md | 1 + src/lib/deskflow/unix/AppUtilUnix.cpp | 2 -- src/lib/platform/CMakeLists.txt | 52 ++++++++++++++------------- src/unittests/deskflow/CMakeLists.txt | 4 +-- src/unittests/platform/CMakeLists.txt | 16 +++++---- 7 files changed, 48 insertions(+), 37 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 98ee53386..9aecdc447 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -156,6 +156,12 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") # Instead use Q_SIGNAL, Q_SLOT and Q_EMIT # prevents issues when used with glib for libportal add_definitions(-DQT_NO_KEYWORDS) + +#Options for Linux platform support +if(UNIX AND NOT APPLE) + option(BUILD_X11_SUPPORT "Build with x11 support" ON) +endif() + include(cmake/Libraries.cmake) configure_libs() diff --git a/cmake/Libraries.cmake b/cmake/Libraries.cmake index a92287573..cc045fa79 100644 --- a/cmake/Libraries.cmake +++ b/cmake/Libraries.cmake @@ -145,7 +145,9 @@ macro(configure_unix_libs) add_definitions(-DWINAPI_CARBON=1) else() - configure_xorg_libs() + if (BUILD_X11_SUPPORT) + configure_xorg_libs() + endif() include(FindPkgConfig) find_package(PkgConfig) diff --git a/doc/dev/build.md b/doc/dev/build.md index ea487af33..337979115 100644 --- a/doc/dev/build.md +++ b/doc/dev/build.md @@ -26,6 +26,7 @@ CMake options: | BUILD_DEV_DOCS | Build development documentation | OFF | `Doxygen` | | BUILD_INSTALLER | Build installers/packages | ON | | | BUILD_TESTS | Build unit tests and legacy tests | ON | `gtest`| +| BUILD_X11_SUPPORT | Build X11 backend (linux and bsd only) | ON | `x11 libs`| | ENABLE_COVERAGE | Enable test coverage | OFF | `gcov` | | SKIP_BUILD_TESTS | Skip running of tests at build time | OFF | | | VCPKG_QT | Build Qt w/ vcpkg (windows only) | OFF | | diff --git a/src/lib/deskflow/unix/AppUtilUnix.cpp b/src/lib/deskflow/unix/AppUtilUnix.cpp index 332cb47b5..e717c7554 100644 --- a/src/lib/deskflow/unix/AppUtilUnix.cpp +++ b/src/lib/deskflow/unix/AppUtilUnix.cpp @@ -15,8 +15,6 @@ #elif WINAPI_CARBON #include #include -#else -#error Platform not supported. #endif #include diff --git a/src/lib/platform/CMakeLists.txt b/src/lib/platform/CMakeLists.txt index d3a2ba180..0900a7ec6 100644 --- a/src/lib/platform/CMakeLists.txt +++ b/src/lib/platform/CMakeLists.txt @@ -99,31 +99,35 @@ elseif(UNIX) XDGPowerManager.h XDGKeyUtil.h XDGKeyUtil.cpp - XWindowsClipboard.cpp - XWindowsClipboard.h - XWindowsClipboardAnyBitmapConverter.cpp - XWindowsClipboardAnyBitmapConverter.h - XWindowsClipboardBMPConverter.cpp - XWindowsClipboardBMPConverter.h - XWindowsClipboardHTMLConverter.cpp - XWindowsClipboardHTMLConverter.h - XWindowsClipboardTextConverter.cpp - XWindowsClipboardTextConverter.h - XWindowsClipboardUCS2Converter.cpp - XWindowsClipboardUCS2Converter.h - XWindowsClipboardUTF8Converter.cpp - XWindowsClipboardUTF8Converter.h - XWindowsEventQueueBuffer.cpp - XWindowsEventQueueBuffer.h - XWindowsKeyState.cpp - XWindowsKeyState.h - XWindowsScreen.cpp - XWindowsScreen.h - XWindowsScreenSaver.cpp - XWindowsScreenSaver.h - XWindowsUtil.cpp - XWindowsUtil.h ) + if (BUILD_X11_SUPPORT) + list(APPEND PLATFORM_SOURCES + XWindowsClipboard.cpp + XWindowsClipboard.h + XWindowsClipboardAnyBitmapConverter.cpp + XWindowsClipboardAnyBitmapConverter.h + XWindowsClipboardBMPConverter.cpp + XWindowsClipboardBMPConverter.h + XWindowsClipboardHTMLConverter.cpp + XWindowsClipboardHTMLConverter.h + XWindowsClipboardTextConverter.cpp + XWindowsClipboardTextConverter.h + XWindowsClipboardUCS2Converter.cpp + XWindowsClipboardUCS2Converter.h + XWindowsClipboardUTF8Converter.cpp + XWindowsClipboardUTF8Converter.h + XWindowsEventQueueBuffer.cpp + XWindowsEventQueueBuffer.h + XWindowsKeyState.cpp + XWindowsKeyState.h + XWindowsScreen.cpp + XWindowsScreen.h + XWindowsScreenSaver.cpp + XWindowsScreenSaver.h + XWindowsUtil.cpp + XWindowsUtil.h + ) + endif() if(LIBEI_FOUND) list(APPEND PLATFORM_SOURCES diff --git a/src/unittests/deskflow/CMakeLists.txt b/src/unittests/deskflow/CMakeLists.txt index 8bd3470ac..e2d05e963 100644 --- a/src/unittests/deskflow/CMakeLists.txt +++ b/src/unittests/deskflow/CMakeLists.txt @@ -45,9 +45,7 @@ create_test( WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/src/lib/deskflow" ) - -if(UNIX AND NOT APPLE) - #this test does not work properly on windows / mac os +if(BUILD_X11_SUPPORT) create_test( NAME X11LayoutParserTests DEPENDS app diff --git a/src/unittests/platform/CMakeLists.txt b/src/unittests/platform/CMakeLists.txt index 1ae3624bb..ffbfa36eb 100644 --- a/src/unittests/platform/CMakeLists.txt +++ b/src/unittests/platform/CMakeLists.txt @@ -25,11 +25,13 @@ elseif(APPLE) WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/src/lib/platform" ) elseif(UNIX) - create_test( - NAME XWindowsClipboardTests - DEPENDS platform - LIBS base arch - SOURCE XWindowsClipboardTests.cpp - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/src/lib/platform" - ) + if (BUILD_X11_SUPPORT) + create_test( + NAME XWindowsClipboardTests + DEPENDS platform + LIBS base arch + SOURCE XWindowsClipboardTests.cpp + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/src/lib/platform" + ) + endif() endif()