Find QtKeychain by its cmake target

This commit is contained in:
Matthias Kuhn 2024-02-10 08:40:14 +01:00 committed by Nyall Dawson
parent 3a18496f7c
commit b9e859f0ed
7 changed files with 26 additions and 65 deletions

View File

@ -568,7 +568,11 @@ if(WITH_CORE)
endif()
# Password helper
find_package(QtKeychain REQUIRED)
if(BUILD_WITH_QT6)
find_package(Qt6Keychain CONFIG REQUIRED)
else()
find_package(Qt5Keychain CONFIG REQUIRED)
endif()
# Master password hash and authentication encryption
find_package(QCA REQUIRED)
# Check for runtime dependency of qca-ossl plugin

View File

@ -1,52 +0,0 @@
# Find QtKeychain
# ~~~~~~~~~~~~~~~
# Copyright (c) 2016, Boundless Spatial
# Author: Larry Shaffer <lshaffer (at) boundlessgeo (dot) com>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
# CMake module to search for QtKeychain library from:
# https://github.com/frankosterfeld/qtkeychain
#
# If it's found it sets QTKEYCHAIN_FOUND to TRUE
# and following variables are set:
# QTKEYCHAIN_INCLUDE_DIR
# QTKEYCHAIN_LIBRARY
FIND_PATH(QTKEYCHAIN_INCLUDE_DIR keychain.h
PATHS
${LIB_DIR}/include
"$ENV{LIB_DIR}/include"
$ENV{INCLUDE}
/usr/local/include
/usr/include
PATH_SUFFIXES ${QT_VERSION_BASE_LOWER}keychain qtkeychain
)
FIND_LIBRARY(QTKEYCHAIN_LIBRARY NAMES ${QT_VERSION_BASE_LOWER}keychain qtkeychain
PATHS
${LIB_DIR}
"$ENV{LIB_DIR}"
$ENV{LIB_DIR}/lib
$ENV{LIB}
/usr/local/lib
/usr/lib
)
IF (QTKEYCHAIN_INCLUDE_DIR AND QTKEYCHAIN_LIBRARY)
SET(QTKEYCHAIN_FOUND TRUE)
ELSE()
SET(QTKEYCHAIN_FOUND FALSE)
ENDIF (QTKEYCHAIN_INCLUDE_DIR AND QTKEYCHAIN_LIBRARY)
IF (QTKEYCHAIN_FOUND)
IF (NOT QTKEYCHAIN_FIND_QUIETLY)
MESSAGE(STATUS "Found QtKeychain: ${QTKEYCHAIN_LIBRARY}")
ENDIF (NOT QTKEYCHAIN_FIND_QUIETLY)
ELSE (QTKEYCHAIN_FOUND)
IF (QTKEYCHAIN_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find QtKeychain")
ENDIF (QTKEYCHAIN_FIND_REQUIRED)
ENDIF (QTKEYCHAIN_FOUND)

View File

@ -4,7 +4,11 @@
#include "o0keychainstore.h"
#include <QDebug>
#include <keychain.h>
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <qt6keychain/keychain.h>
#else
#include <qt5keychain/keychain.h>
#endif
#include <QtCore/QDataStream>
#include <QtCore/QBuffer>
#include <QtCore/QEventLoop>
@ -75,4 +79,4 @@ void o0keyChainStore::clearFromKeychain() {
if ( job.error() ) {
qWarning() << "Deleting keychain failed: " << qPrintable(job.errorString());
}
}
}

View File

@ -3,9 +3,6 @@
########################################################
# Packages
if(NOT QTKEYCHAIN_FOUND)
find_package(QtKeychain REQUIRED)
endif()
option(WITH_INTERNAL_O2 "Download and locally include source of o2 library" ON)
if(WITH_INTERNAL_O2)

View File

@ -2249,7 +2249,6 @@ target_include_directories(qgis_core SYSTEM PUBLIC
${SPATIALINDEX_INCLUDE_DIR} # before GEOS for case-insensitive filesystems
${SQLITE3_INCLUDE_DIR}
${QCA_INCLUDE_DIR}
${QTKEYCHAIN_INCLUDE_DIR}
${${QT_VERSION_BASE}SerialPort_INCLUDE_DIRS}
${Protobuf_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS}
@ -2411,7 +2410,6 @@ target_link_libraries(qgis_core
${QT_VERSION_BASE}::Concurrent
${OPTIONAL_QTWEBKIT}
${QCA_LIBRARY}
${QTKEYCHAIN_LIBRARY}
GEOS::geos_c
GDAL::GDAL
${SPATIALINDEX_LIBRARY}
@ -2424,6 +2422,16 @@ target_link_libraries(qgis_core
PROJ::proj
)
if(BUILD_WITH_QT6)
target_link_libraries(qgis_core
Qt6Keychain::Qt6Keychain
)
else()
target_link_libraries(qgis_core
Qt5Keychain::Qt5Keychain
)
endif()
if (WITH_QTPRINTER)
target_link_libraries(qgis_core ${QT_VERSION_BASE}::PrintSupport)
target_include_directories(qgis_core SYSTEM PUBLIC ${${QT_VERSION_BASE}PrintSupport_INCLUDE_DIRS})

View File

@ -44,9 +44,6 @@
#include <QSslConfiguration>
#endif
// QtKeyChain library
#include "keychain.h"
// QGIS includes
#include "qgsauthcertutils.h"
#include "qgsauthcrypto.h"

View File

@ -38,8 +38,11 @@
#include "qgsauthconfig.h"
#include "qgsauthmethod.h"
// Qt5KeyChain library
#include "keychain.h"
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <qt6keychain/keychain.h>
#else
#include <qt5keychain/keychain.h>
#endif
#ifndef SIP_RUN
namespace QCA