From 1764decd7b7426320f24f3dbde44fc13993d1ed2 Mon Sep 17 00:00:00 2001
From: Andreas Cord-Landwehr <cordlandwehr@kde.org>
Date: Sun, 13 Oct 2024 08:19:16 +0200
Subject: [PATCH] Provide SONNET_NO_BACKENDS option to deactivate build
 failures with no backends

For cross-compilation tooling, both a native host and a target device
build is needed in which the first provides the parsediagrams6
executable. We do not want to build any plugins when just the
cross-build tooling is being built.
---
 CMakeLists.txt             | 1 +
 src/plugins/CMakeLists.txt | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b8e03cf0..b9425a19 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -32,6 +32,7 @@ set(EXCLUDE_DEPRECATED_BEFORE_AND_AT 0 CACHE STRING "Control the range of deprec
 set(REQUIRED_QT_VERSION 6.5.0)
 option(SONNET_USE_WIDGETS "Build components using Qt6Widgets" ON)
 option(SONNET_USE_QML "Build components using Qt6Quick" ON)
+option(SONNET_NO_BACKENDS "Do not fail when no backends are built (to be used for cross-build host tooling)" OFF)
 
 if(SONNET_USE_WIDGETS)
     find_package(Qt6 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Widgets)
diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt
index 85441211..b53c9de7 100644
--- a/src/plugins/CMakeLists.txt
+++ b/src/plugins/CMakeLists.txt
@@ -53,7 +53,7 @@ if (WIN32)
 endif ()
 
 # if we did not find any backend, that is bad
-# do that on Andriod, too, if we have some backend for it
-if (NOT ANDROID AND NOT SONNET_BACKEND_FOUND)
+# do that on Android, too, if we have some backend for it
+if (NOT ANDROID AND NOT SONNET_BACKEND_FOUND AND NOT SONNET_NO_BACKENDS)
     message(FATAL_ERROR "Can not build any backend plugin for Sonnet.")
 endif ()
-- 
GitLab

