Favor QtKeychain installed together with Qt
authorJocelyn Turcotte <jturcotte@woboq.com>
Mon, 8 May 2017 16:19:29 +0000 (18:19 +0200)
committerJocelyn Turcotte <jturcotte@woboq.com>
Mon, 8 May 2017 21:18:06 +0000 (23:18 +0200)
By default we will look in /usr/lib, which would prevent us from
using a different path for Qt as QtKeychain depends on Qt itself.

cmake/modules/FindQt5Keychain.cmake

index 809b9d659d649a0704e6845dee4d25463e19376a..6848763fe7f2026a8dfd9bd1c52daf05733e27bf 100644 (file)
@@ -9,9 +9,17 @@
 #  QTKEYCHAIN_LIBRARIES - The libraries needed to use QtKeychain
 #  QTKEYCHAIN_DEFINITIONS - Compiler switches required for using LibXml2
 
+# When we build our own Qt we also need to build QtKeychain with it
+# so that it doesn't pull a different Qt version. For that reason
+# first look in the Qt lib directory for QtKeychain.
+get_target_property(_QTCORE_LIB_PATH Qt5::Core IMPORTED_LOCATION_RELEASE)
+get_filename_component(QT_LIB_DIR "${_QTCORE_LIB_PATH}" DIRECTORY)
+
 find_path(QTKEYCHAIN_INCLUDE_DIR
             NAMES
               keychain.h
+            HINTS
+               ${QT_LIB_DIR}/../include
             PATH_SUFFIXES
               qt5keychain
             )
@@ -20,6 +28,8 @@ find_library(QTKEYCHAIN_LIBRARY
             NAMES
               qt5keychain
               lib5qtkeychain
+            HINTS
+               ${QT_LIB_DIR}
             PATHS
                /usr/lib
                /usr/lib/${CMAKE_ARCH_TRIPLET}