From 8474e4f26d58e4369ccd47b346706c8ab0bb3ec8 Mon Sep 17 00:00:00 2001 From: Matthias Klumpp Date: Fri, 14 Jun 2024 00:36:27 +0200 Subject: [PATCH] Add version test macro for PackageKitQt --- CMakeLists.txt | 2 +- src/CMakeLists.txt | 6 +++++- src/PackageKitQt | 6 ++++++ src/packagekitqt_global.h | 2 ++ src/qpk-version.h.in | 36 ++++++++++++++++++++++++++++++++++++ 5 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 src/PackageKitQt create mode 100644 src/qpk-version.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 92c7d72..46aae35 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.2) +cmake_minimum_required(VERSION 3.6) cmake_policy(SET CMP0048 NEW) if (POLICY CMP0043) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4d5e563..fd3e268 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,7 @@ # CMakeLists for PackageKit-Qt library set(packagekitqt_HEADERS + PackageKitQt Daemon Transaction common.h @@ -24,6 +25,9 @@ set(packagekitqt_SRC offline.cpp ) +set(QPK_VERSION_HDR ${CMAKE_CURRENT_BINARY_DIR}/qpk-version.h) +configure_file(qpk-version.h.in ${QPK_VERSION_HDR}) + find_path(PK_INTERFACES_DIR org.freedesktop.PackageKit.xml HINTS ${CMAKE_INSTALL_PREFIX} /usr PATH_SUFFIXES share/dbus-1/interfaces/ @@ -60,7 +64,7 @@ install(TARGETS packagekitqt${QT_VERSION_MAJOR} EXPORT PackageKitQtTargets DESTI install(FILES ${CMAKE_CURRENT_BINARY_DIR}/packagekitqt${QT_VERSION_MAJOR}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig ) -install(FILES ${packagekitqt_HEADERS} +install(FILES ${packagekitqt_HEADERS} ${QPK_VERSION_HDR} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/packagekitqt${QT_VERSION_MAJOR}/PackageKit/ ) diff --git a/src/PackageKitQt b/src/PackageKitQt new file mode 100644 index 0000000..346ffc2 --- /dev/null +++ b/src/PackageKitQt @@ -0,0 +1,6 @@ + +#pragma once +#include "daemon.h" +#include "details.h" +#include "offline.h" +#include "transaction.h" diff --git a/src/packagekitqt_global.h b/src/packagekitqt_global.h index e6c82a4..e8b81e9 100644 --- a/src/packagekitqt_global.h +++ b/src/packagekitqt_global.h @@ -9,4 +9,6 @@ # define PACKAGEKITQT_LIBRARY Q_DECL_IMPORT #endif +#include "qpk-version.h" + #endif // PACKAGEKITQT_GLOBAL_H diff --git a/src/qpk-version.h.in b/src/qpk-version.h.in new file mode 100644 index 0000000..31c1568 --- /dev/null +++ b/src/qpk-version.h.in @@ -0,0 +1,36 @@ +/* + * This file is part of the PackageKitQt project + * Copyright (C) 2021-2024 Matthias Klumpp + * + * Licensed under the GNU Lesser General Public License Version 2.1 + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 2.1 of the license, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see . + */ + +#pragma once + +/* compile time version + */ +#define QPK_MAJOR_VERSION @packagekit-qt_VERSION_MAJOR@ +#define QPK_MINOR_VERSION @packagekit-qt_VERSION_MINOR@ +#define QPK_MICRO_VERSION @packagekit-qt_VERSION_PATCH@ + +/* check whether a PackageKitQt version equal to or greater than + * major.minor.micro. + */ +#define QPK_CHECK_VERSION(major,minor,micro) \ + (QPK_MAJOR_VERSION > (major) || \ + (QPK_MAJOR_VERSION == (major) && QPK_MINOR_VERSION > (minor)) || \ + (QPK_MAJOR_VERSION == (major) && QPK_MINOR_VERSION == (minor) && \ + QPK_MICRO_VERSION >= (micro)))