From f3a754ddcbc8a086ca48920bd33e96082cef699c Mon Sep 17 00:00:00 2001
From: Pino Toscano <pino@kde.org>
Date: Mon, 2 Nov 2020 13:10:45 +0100
Subject: [PATCH] cmake: build test_ktechlab only if testing is enabled

The test_ktechlab static library basically builds almost all the
ktechlab sources, resulting in a "double build" in case testing is
enabled. Considering that is used only by test binaries built only
when testing is enabled, then limit its build accordingly.
---
 src/CMakeLists.txt | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -379,19 +379,23 @@ install(TARGETS ktechlab ${INSTALL_TARGE
 
 # for helping testing
 
-add_library(test_ktechlab STATIC ${ktechlab_SRCS})
+if(BUILD_TESTING)
 
-target_link_libraries(test_ktechlab
-    KF5::TextEditor
-    KF5::IconThemes
-    KF5::Parts
-    KF5::KHtml
-    KF5::WidgetsAddons
-    KF5::WindowSystem
-
-    Qt5::Widgets
-    Qt5::PrintSupport
-)
+    add_library(test_ktechlab STATIC ${ktechlab_SRCS})
+
+    target_link_libraries(test_ktechlab
+        KF5::TextEditor
+        KF5::IconThemes
+        KF5::Parts
+        KF5::KHtml
+        KF5::WidgetsAddons
+        KF5::WindowSystem
+
+        Qt5::Widgets
+        Qt5::PrintSupport
+    )
+
+endif()
 
 ########### install files ###############
 
