From d290b2a51d5aa4694ec746ce5cc9456977efde71 Mon Sep 17 00:00:00 2001 From: Andreas Sturmlechner Date: Sun, 31 Jul 2022 16:17:30 +0200 Subject: [PATCH] Add CMake option to build WITHOUT_X11 We want to be able to build without X11 support even if some of the used libraries may not work w/o X11 themselves yet or need to be built with X11 support for other reverse dependencies. KTOUCH_BUILD_WITH_X11 already exists and is set automagically so far, but using -DCMAKE_DISABLE_FIND_PACKAGE_X11 will break if any dependencies list X11 as required in their cmake config. Introducing this option means there is no behavior change by default, cmake will just skip finding X11 or adding unwanted features if the option is enabled. - Move the checks to root CMakeLists.txt - Move finding Qt5X11Extras behind "NOT WITHOUT_X11" too - x11_helper is conditional on KTOUCH_BUILD_WITH_X11 Signed-off-by: Andreas Sturmlechner --- CMakeLists.txt | 18 +++++++++++++++--- src/CMakeLists.txt | 13 +------------ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ec74a5..a05231b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,9 +39,6 @@ find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} REQUIRED COMPONENTS Xml XmlPatterns ) -if (QT_MAJOR_VERSION STREQUAL "5") -find_package(Qt5X11Extras) -endif() find_package(Qt${QT_MAJOR_VERSION} CONFIG QUIET OPTIONAL_COMPONENTS QuickCompiler) find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS @@ -62,6 +59,21 @@ find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS option(COMPILE_QML "Precompile QML code" OFF) +option(WITHOUT_X11 "Build without X11 Keyboard Layout Detection (skips finding X11)" OFF) + +if (NOT WITHOUT_X11) + find_package(X11) + find_package(XCB OPTIONAL_COMPONENTS XCB XKB) + if (QT_MAJOR_VERSION STREQUAL "5") + find_package(Qt5X11Extras ${QT_MIN_VERSION} CONFIG) + endif() + + if (Qt5X11Extras_FOUND AND X11_FOUND AND X11_Xkbfile_FOUND AND X11_Xkb_FOUND AND XCB_FOUND AND XCB_XKB_FOUND) + set(KTOUCH_BUILD_WITH_X11 TRUE) + endif() + + add_feature_info ("Keyboard Layout Detection" KTOUCH_BUILD_WITH_X11 "needs Qt5X11Extras, libX11, libxkb, libxkbfile, libxcb, and libxcb-xkb") +endif() # enable QML debugging for debug builds set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DQT_QML_DEBUG") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cb6f3f5..9dd2a5f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,15 +4,6 @@ ecm_setup_version(${RELEASE_SERVICE_VERSION} PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KTouchConfigVersion.cmake" ) -find_package(X11) -find_package(XCB OPTIONAL_COMPONENTS XCB XKB) - -if (Qt5X11Extras_FOUND AND X11_FOUND AND X11_Xkbfile_FOUND AND X11_Xkb_FOUND AND XCB_FOUND AND XCB_XKB_FOUND) - set(KTOUCH_BUILD_WITH_X11 TRUE) -endif() - -add_feature_info ("Keyboard Layout Detection" KTOUCH_BUILD_WITH_X11 "needs Qt5X11Extras, libX11, libxkb, libxkbfile, libxcb, and libxcb-xkb") - ecm_optional_add_subdirectory(schemata) # set include directories @@ -137,9 +128,7 @@ set(ktouch_SRCS undocommands/coursecommands.cpp undocommands/coursecommands.h undocommands/keyboardlayoutcommands.cpp - undocommands/keyboardlayoutcommands.h - x11_helper.cpp - x11_helper.h) + undocommands/keyboardlayoutcommands.h) qt_add_resources(ktouch_imgs_SRCS images/images.qrc) -- GitLab