From 3fc9b69567f974219b8f5368af273d33e0e3331e Mon Sep 17 00:00:00 2001 From: Bart Ribbers Date: Fri, 3 Apr 2020 17:36:15 +0200 Subject: [PATCH 1/2] Port to CMake qmake won't be available anymore in Qt6 and they're switching to CMake, so let's do the same --- CMakeLists.txt | 21 +++++++++++ dbusextended-qt.pro | 2 - src/CMakeLists.txt | 65 +++++++++++++++++++++++++++++++++ src/dbusextended-qt5.prf.in | 2 +- src/dbusextended.pc.in | 11 ++++++ src/dbusextendedConfig.cmake.in | 7 ++++ src/src.pro | 45 ----------------------- 7 files changed, 105 insertions(+), 48 deletions(-) create mode 100644 CMakeLists.txt delete mode 100644 dbusextended-qt.pro create mode 100644 src/CMakeLists.txt create mode 100644 src/dbusextended.pc.in create mode 100644 src/dbusextendedConfig.cmake.in delete mode 100644 src/src.pro diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..3698f0b --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.1.0) + +project(dbusextended + VERSION 0.0.3 + DESCRIPTION "Provides additional features to the QDBusAbstractInterface class") + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +include(FeatureSummary) +include(GNUInstallDirs) + +set(QT_MIN_VERSION "5.6.0") +find_package(Qt5 COMPONENTS Core DBus REQUIRED) + +add_subdirectory(src) + +feature_summary(WHAT PACKAGES_FOUND PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/dbusextended-qt.pro b/dbusextended-qt.pro deleted file mode 100644 index 65d9262..0000000 --- a/dbusextended-qt.pro +++ /dev/null @@ -1,2 +0,0 @@ -TEMPLATE = subdirs -SUBDIRS = src diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..bf3d031 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,65 @@ +set(SRC + dbusextendedabstractinterface.cpp + dbusextendedpendingcallwatcher.cpp + dbusextended.h + dbusextendedabstractinterface.h) +set(HEADERS + dbusextended.h + dbusextendedabstractinterface.h + DBusExtended + DBusExtendedAbstractInterface) + +add_library(dbusextended SHARED ${SRC}) + +target_link_libraries(dbusextended + Qt5::Core + Qt5::DBus) +target_include_directories(dbusextended PUBLIC + $ + $) + +set_target_properties(dbusextended PROPERTIES + SOVERSION ${PROJECT_VERSION_MAJOR} + VERSION ${PROJECT_VERSION}) + +# Create pkgconfig file +configure_file(dbusextended.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/dbusextended-qt5.pc + @ONLY) + +configure_file(dbusextended-qt5.prf.in + ${CMAKE_CURRENT_BINARY_DIR}/dbusextended-qt5.prf + @ONLY) + +install(TARGETS dbusextended + EXPORT dbusextendedTargets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) +install(FILES ${HEADERS} DESTINATION + ${CMAKE_INSTALL_INCLUDEDIR}/dbusextended) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dbusextended-qt5.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dbusextended-qt5.prf + DESTINATION ${CMAKE_INSTALL_LIBDIR}/qt5/mkspecs/features/) + +# Configure and install the CMake Config File +include(CMakePackageConfigHelpers) + +configure_package_config_file( + "dbusextendedConfig.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/dbusextendedConfig.cmake" + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/dbusextended/) +write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/dbusextendedConfigVersion.cmake + VERSION ${dbusextended_VERSION} + COMPATIBILITY AnyNewerVersion) + +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/dbusextendedConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/dbusextendedConfigVersion.cmake" + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/dbusextended/ + COMPONENT Devel) +export(TARGETS dbusextended FILE dbusextendedTargets.cmake) +install(EXPORT dbusextendedTargets + FILE dbusextendedTargets.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/dbusextended/ + COMPONENT Devel) + diff --git a/src/dbusextended-qt5.prf.in b/src/dbusextended-qt5.prf.in index 63c81dd..5cace20 100644 --- a/src/dbusextended-qt5.prf.in +++ b/src/dbusextended-qt5.prf.in @@ -1,2 +1,2 @@ CONFIG += link_pkgconfig -PKGCONFIG += $$TARGET +PKGCONFIG += @PROJECT_NAME@ diff --git a/src/dbusextended.pc.in b/src/dbusextended.pc.in new file mode 100644 index 0000000..07c34d3 --- /dev/null +++ b/src/dbusextended.pc.in @@ -0,0 +1,11 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ +includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@/@PROJECT_NAME@ + +Name: @PROJECT_NAME@ +Description: @PROJECT_DESCRIPTION@ +Version: @PROJECT_VERSION@ +Libs: -l@PROJECT_NAME@ +Cflags: -I${includedir} +Requires: Qt5Core Qt5DBus diff --git a/src/dbusextendedConfig.cmake.in b/src/dbusextendedConfig.cmake.in new file mode 100644 index 0000000..a5f86b4 --- /dev/null +++ b/src/dbusextendedConfig.cmake.in @@ -0,0 +1,7 @@ +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) +find_dependency(Qt5Core @REQUIRED_QT_VERSION@) + +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") +@PACKAGE_INCLUDE_QCHTARGETS@ diff --git a/src/src.pro b/src/src.pro deleted file mode 100644 index e9c2c28..0000000 --- a/src/src.pro +++ /dev/null @@ -1,45 +0,0 @@ -include(../common.pri) - -TEMPLATE = lib -CONFIG += qt - -QT = core dbus - -TARGET = $${QTDBUSEXTENDEDLIB} - -QMAKE_SUBSTITUTES = $${TARGET}.prf.in - -DEFINES += QT_DBUS_EXTENDED_LIBRARY - -# Generate pkg-config support by default -# Note that we HAVE TO also create prl config as QMake implementation -# mixes both of them together. -CONFIG += create_pc create_prl no_install_prl - -SOURCES += \ - dbusextendedabstractinterface.cpp \ - dbusextendedpendingcallwatcher.cpp - -HEADERS += \ - dbusextended.h \ - dbusextendedabstractinterface.h \ - dbusextendedpendingcallwatcher_p.h - -INSTALL_HEADERS = \ - DBusExtended \ - DBusExtendedAbstractInterface \ - dbusextended.h \ - dbusextendedabstractinterface.h - -target.path = $$[QT_INSTALL_LIBS] -headers.files = $$INSTALL_HEADERS -headers.path = $$[QT_INSTALL_HEADERS]/DBusExtended -prf.files = $${TARGET}.prf -prf.path = $$[QMAKE_MKSPECS]/features -INSTALLS += target headers prf - -QMAKE_PKGCONFIG_LIBDIR = $$target.path -QMAKE_PKGCONFIG_INCDIR = $$headers.path -QMAKE_PKGCONFIG_DESTDIR = pkgconfig -QMAKE_PKGCONFIG_NAME = DBusExtended -QMAKE_PKGCONFIG_REQUIRES += Qt5Core Qt5DBus From 74ce7daeee0bba1afa3c6ea97bebf15b0fbe6a24 Mon Sep 17 00:00:00 2001 From: Bart Ribbers Date: Fri, 3 Apr 2020 17:41:36 +0200 Subject: [PATCH 2/2] [packaging] Adapt to CMake build system --- rpm/dbusextended.spec | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/rpm/dbusextended.spec b/rpm/dbusextended.spec index a749301..5300fd1 100644 --- a/rpm/dbusextended.spec +++ b/rpm/dbusextended.spec @@ -9,6 +9,7 @@ URL: https://github.com/nemomobile/qtdbusextended Source0: %{name}-%{version}.tar.bz2 Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig +BuildRequires: cmake BuildRequires: pkgconfig(Qt5Core) BuildRequires: pkgconfig(Qt5DBus) @@ -26,15 +27,20 @@ Development files for %{name}. %setup -q -n %{name}-%{version} %build - -%qmake5 - -make %{?_smp_mflags} +mkdir build +cd build +cmake \ + -DCMAKE_BUILD_TYPE=None \ + -DCMAKE_INSTALL_PREFIX=%{_prefix} \ + -DCMAKE_INSTALL_LIBDIR=%{_lib} \ + -DCMAKE_VERBOSE_MAKEFILE=ON \ + .. +cmake --build . %install +cd build rm -rf %{buildroot} - -%qmake5_install +DESTDIR=%{buildroot} cmake --build . --target install %post -p /sbin/ldconfig @@ -47,9 +53,10 @@ rm -rf %{buildroot} %files devel %defattr(-,root,root,-) %{_datarootdir}/qt5/mkspecs/features/%{name}.prf -%{_includedir}/qt5/DBusExtended/DBusExtended -%{_includedir}/qt5/DBusExtended/DBusExtendedAbstractInterface -%{_includedir}/qt5/DBusExtended/dbusextended.h -%{_includedir}/qt5/DBusExtended/dbusextendedabstractinterface.h +%{_includedir}/dbusextended/DBusExtended +%{_includedir}/dbusextended/DBusExtendedAbstractInterface +%{_includedir}/dbusextended/dbusextended.h +%{_includedir}/dbusextended/dbusextendedabstractinterface.h %{_libdir}/lib*.so %{_libdir}/pkgconfig/%{name}.pc +%{_libdir}/cmake/dbusextended/*.cmake