From 618e3f3ba195a3b50812d1184ebf90555d659055 Mon Sep 17 00:00:00 2001
From: Andreas Sturmlechner <andreas.sturmlechner@gmail.com>
Date: Sun, 17 Feb 2019 23:51:03 +0100
Subject: [PATCH] Un-break optional Qt5/KF5 detection

And if we enable an option, make the necessary libraries REQUIRED.
---
 core/CMakeLists.txt | 50 +++++++++++++--------------------------------
 1 file changed, 14 insertions(+), 36 deletions(-)

diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
index de599ee881..8aef35e062 100644
--- a/core/CMakeLists.txt
+++ b/core/CMakeLists.txt
@@ -65,17 +65,14 @@ find_package(Qt5 ${QT_MIN_VERSION} REQUIRED
 )
 
 if(ENABLE_QWEBENGINE)
-    find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS WebEngineWidgets)
+    find_package(Qt5WebEngineWidgets ${QT_MIN_VERSION} REQUIRED NO_MODULE)
 else()
-    find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS WebKitWidgets)
+    find_package(Qt5WebKitWidgets ${QT_MIN_VERSION} REQUIRED NO_MODULE)
 endif()
 
-find_package(Qt5 ${QT_MIN_VERSION}
-             OPTIONAL_COMPONENTS
-             DBus
-             OpenGL
-             XmlPatterns                # For Rajce plugin
-)
+find_package(Qt5DBus ${QT_MIN_VERSION})
+find_package(Qt5OpenGL ${QT_MIN_VERSION})
+find_package(Qt5XmlPatterns ${QT_MIN_VERSION}) # For Rajce plugin
 
 if(ENABLE_DBUS)
     if(NOT Qt5DBus_FOUND)
@@ -86,16 +83,11 @@ endif()
 # Dependencies For unit tests and CLI test tools
 
 if(BUILD_TESTING)
-    find_package(Qt5 ${QT_MIN_VERSION} REQUIRED
-                 NO_MODULE COMPONENTS
-                 Test
-    )
+    find_package(Qt5Test ${QT_MIN_VERSION} NO_MODULE)
 
-    find_package(Qt5 ${QT_MIN_VERSION}
-                 QUIET
-                 OPTIONAL_COMPONENTS
-                 Qml WebView  # Optional, for 'sialis' O2 library test tool.
-    )
+    # Optional, for 'sialis' O2 library test tool.
+    find_package(Qt5Qml ${QT_MIN_VERSION} QUIET NO_MODULE)
+    find_package(Qt5WebView ${QT_MIN_VERSION} QUIET NO_MODULE)
 endif()
 
 find_package(KF5 ${KF5_MIN_VERSION} REQUIRED
@@ -121,7 +113,7 @@ find_package(KF5 ${KF5_MIN_VERSION} QUIET
 if(ENABLE_KFILEMETADATASUPPORT)
 
     find_package(KF5 ${KF5_MIN_VERSION}
-                 QUIET
+                 REQUIRED
                  OPTIONAL_COMPONENTS
                  FileMetaData           # For Plasma destop file indexer support.
     )
@@ -130,7 +122,7 @@ endif()
 
 if(ENABLE_AKONADICONTACTSUPPORT)
 
-    find_package(KF5 ${AKONADI_MIN_VERSION} QUIET
+    find_package(KF5 ${AKONADI_MIN_VERSION} REQUIRED
                  OPTIONAL_COMPONENTS
                  AkonadiContact         # For KDE Mail Contacts support.
                  Contacts               # API for contacts/address book data.
@@ -138,28 +130,14 @@ if(ENABLE_AKONADICONTACTSUPPORT)
 
 endif()
 
-find_package(KF5 ${KSANE_MIN_VERSION} QUIET
-             OPTIONAL_COMPONENTS
-             Sane                   # For digital scanner support.
-)
+find_package(KF5Sane ${KSANE_MIN_VERSION} QUIET) # For digital scanner support.
 
-find_package(KF5 ${CALENDAR_MIN_VERSION} QUIET
-             OPTIONAL_COMPONENTS
-             CalendarCore           # For Calendar tool.
-)
+find_package(KF5CalendarCore ${CALENDAR_MIN_VERSION} QUIET) # For Calendar tool.
 
 if ("${KF5CalendarCore_VERSION}" VERSION_GREATER 5.6.40)
     set(HAVE_KCALENDAR_QDATETIME TRUE)
 endif()
 
-if(ENABLE_AKONADICONTACTSUPPORT AND (NOT KF5AkonadiContact_FOUND OR NOT KF5Contacts_FOUND))
-    set(ENABLE_AKONADICONTACTSUPPORT OFF)
-endif()
-
-if(ENABLE_KFILEMETADATASUPPORT AND NOT KF5FileMetaData_FOUND)
-    set(ENABLE_KFILEMETADATASUPPORT OFF)
-endif()
-
 # Check if KIO have been compiled with KIOWidgets. digiKam only needs this one.
 if(KF5KIO_FOUND)
     get_target_property(KIOWidgets_INCLUDE_DIRS KF5::KIOWidgets
@@ -296,7 +274,7 @@ endif()
 find_package(X11)
 
 if(X11_FOUND)
-    find_package(Qt5 ${QT_MIN_VERSION} NO_MODULE COMPONENTS X11Extras)
+    find_package(Qt5X11Extras ${QT_MIN_VERSION} NO_MODULE)
     set(HAVE_X11 TRUE)
 else()
     set(HAVE_X11 FALSE)
-- 
2.37.3

