# upstream PR: <https://github.com/equalsraf/neovim-qt/pull/1007>

From dd334be1e113d9e0f2310cc35b620c5090d06e1f Mon Sep 17 00:00:00 2001
From: tastytea <tastytea@tastytea.de>
Date: Tue, 9 Aug 2022 15:32:08 +0200
Subject: [PATCH] only require Qt5Test if tests are enabled

---
 CMakeLists.txt                     | 2 +-
 src/gui/shellwidget/CMakeLists.txt | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8c77d27..ed02426 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -135,7 +135,6 @@ set(CMAKE_AUTOMOC ON)
 find_package(Qt5Core REQUIRED)
 find_package(Qt5Network REQUIRED)
 find_package(Qt5Svg REQUIRED)
-find_package(Qt5Test REQUIRED)
 find_package(Qt5Widgets REQUIRED)
 
 if(Qt5Core_VERSION VERSION_LESS 5.8)
@@ -176,6 +175,7 @@ add_subdirectory(doc)
 
 option(ENABLE_TESTS "Build tests" ON)
 if(ENABLE_TESTS)
+	find_package(Qt5Test REQUIRED)
 	enable_testing()
 	add_subdirectory(test)
 	add_subdirectory(src/gui/shellwidget/test)
diff --git a/src/gui/shellwidget/CMakeLists.txt b/src/gui/shellwidget/CMakeLists.txt
index f456c4a..41bc382 100644
--- a/src/gui/shellwidget/CMakeLists.txt
+++ b/src/gui/shellwidget/CMakeLists.txt
@@ -9,7 +9,9 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
 # Qt
 set(CMAKE_AUTOMOC ON)
 find_package(Qt5Widgets REQUIRED)
-find_package(Qt5Test REQUIRED)
+if(ENABLE_TESTS)
+	find_package(Qt5Test REQUIRED)
+endif()
 
 if (WIN32 AND USE_STATIC_QT)
 	add_definitions(-DUSE_STATIC_QT)
-- 
2.35.1

