Skip to content

Commit

Permalink
Add version test macro for PackageKitQt
Browse files Browse the repository at this point in the history
  • Loading branch information
ximion committed Jun 13, 2024
1 parent d0299ac commit 8474e4f
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.2)
cmake_minimum_required(VERSION 3.6)
cmake_policy(SET CMP0048 NEW)

if (POLICY CMP0043)
Expand Down
6 changes: 5 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# CMakeLists for PackageKit-Qt library

set(packagekitqt_HEADERS
PackageKitQt
Daemon
Transaction
common.h
Expand All @@ -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/
Expand Down Expand Up @@ -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/
)

Expand Down
6 changes: 6 additions & 0 deletions src/PackageKitQt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

#pragma once
#include "daemon.h"
#include "details.h"
#include "offline.h"
#include "transaction.h"
2 changes: 2 additions & 0 deletions src/packagekitqt_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@
# define PACKAGEKITQT_LIBRARY Q_DECL_IMPORT
#endif

#include "qpk-version.h"

#endif // PACKAGEKITQT_GLOBAL_H
36 changes: 36 additions & 0 deletions src/qpk-version.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* This file is part of the PackageKitQt project
* Copyright (C) 2021-2024 Matthias Klumpp <[email protected]>
*
* 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 <http://www.gnu.org/licenses/>.
*/

#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)))

0 comments on commit 8474e4f

Please sign in to comment.