From 496979af0920eb27693685dc327c6051f3333ea2 Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Mon, 31 Oct 2016 16:43:44 +0100 Subject: [PATCH] Fix build when disabling libsecret Build when libsecret support is disabled explicitly or if libsecret wasn't found. --- CMakeLists.txt | 4 +++- libsecret.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 423c69a..a72419f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -155,7 +155,9 @@ if(UNIX AND NOT APPLE AND NOT ANDROID) if(LIBSECRET_SUPPORT) pkg_check_modules(LIBSECRET libsecret-1) - add_definitions(-DHAVE_LIBSECRET=${LIBSECRET_FOUND}) + if (LIBSECRET_FOUND) + add_definitions(-DHAVE_LIBSECRET=1) + endif() INCLUDE_DIRECTORIES(${LIBSECRET_INCLUDE_DIRS}) endif() diff --git a/libsecret.cpp b/libsecret.cpp index ad6383b..302651b 100644 --- a/libsecret.cpp +++ b/libsecret.cpp @@ -194,8 +194,8 @@ static QString modeToString(QKeychain::JobPrivate::Mode mode) { #endif bool LibSecretKeyring::isAvailable() { - const LibSecretKeyring& keyring = instance(); #if defined(HAVE_LIBSECRET) + const LibSecretKeyring& keyring = instance(); if (!keyring.isLoaded()) return false; if (secret_password_lookup_fn == NULL) @@ -307,6 +307,7 @@ bool LibSecretKeyring::deletePassword(const QString &key, const QString &service LibSecretKeyring::LibSecretKeyring() : QLibrary("secret-1") { +#ifdef HAVE_LIBSECRET if (load()) { secret_password_lookup_fn = (secret_password_lookup_t)resolve("secret_password_lookup"); @@ -325,6 +326,7 @@ LibSecretKeyring::LibSecretKeyring() secret_error_get_quark_fn = (secret_error_get_quark_t)resolve("secret_error_get_quark"); } +#endif } LibSecretKeyring &LibSecretKeyring::instance() {