git: fc04c6243dd1 - main - devel/libdbusmenu-qt: flavorize to be usable with Qt 5 and Qt 6

From: Tobias C. Berner <tcberner_at_FreeBSD.org>
Date: Tue, 23 Aug 2022 08:16:06 UTC
The branch main has been updated by tcberner:

URL: https://cgit.FreeBSD.org/ports/commit/?id=fc04c6243dd149c48003d649779c0f4e9db3b0df

commit fc04c6243dd149c48003d649779c0f4e9db3b0df
Author:     Tobias C. Berner <tcberner@FreeBSD.org>
AuthorDate: 2022-08-23 07:06:44 +0000
Commit:     Tobias C. Berner <tcberner@FreeBSD.org>
CommitDate: 2022-08-23 07:09:04 +0000

    devel/libdbusmenu-qt: flavorize to be usable with Qt 5 and Qt 6
---
 devel/libdbusmenu-qt/Makefile                   |  19 +-
 devel/libdbusmenu-qt/distinfo                   |   4 +-
 devel/libdbusmenu-qt/files/patch-CMakeLists.txt |  20 --
 devel/libdbusmenu-qt/files/patch-qt6-support    | 253 ++++++++++++++++++++++++
 4 files changed, 268 insertions(+), 28 deletions(-)

diff --git a/devel/libdbusmenu-qt/Makefile b/devel/libdbusmenu-qt/Makefile
index cb09f0430dd5..f521ec9ab28b 100644
--- a/devel/libdbusmenu-qt/Makefile
+++ b/devel/libdbusmenu-qt/Makefile
@@ -1,10 +1,9 @@
 PORTNAME=	libdbusmenu-qt
 PORTVERSION=	${MAJOR_VER}.${SNAPSHOT_VER:S/.//g}
-PORTREVISION=	11
+PORTREVISION=	12
 CATEGORIES=	devel
 MASTER_SITES=	http://archive.ubuntu.com/ubuntu/pool/main/libd/${PORTNAME}/ \
 		LOCAL/tcberner/${PORTNAME}/${PORTVERSION}
-PKGNAMESUFFIX=	5
 DISTNAME=	${PORTNAME}_${MAJOR_VER}+${SNAPSHOT_VER}.orig
 
 MAINTAINER=	kde@FreeBSD.org
@@ -12,13 +11,19 @@ COMMENT=	Qt5 implementation of the DBusMenu protocol
 
 LICENSE=	LGPL20
 
-USES=		compiler:c++11-lib cmake qt:5
+FLAVORS=	qt5 qt6
+FLAVOR?=	qt5
+qt5_PKGNAMESUFFIX=	5
+qt6_PKGNAMESUFFIX=	6
+
+USES=		compiler:c++11-lib cmake qt:${FLAVOR:S/qt//}
 USE_LDCONFIG=	yes
-USE_QT=		core dbus gui widgets \
+_USE_QT5=	core dbus gui widgets \
 		buildtools_build qmake_build
-CMAKE_ON=	USE_QT5
-CMAKE_OFF=	USE_QT4
-QTVER_SUFFIX=	5
+_USE_QT6=	base
+USE_QT=		${_USE_QT${FLAVOR:S/qt//}}
+CMAKE_ON=	USE_QT${FLAVOR:S/qt//}
+QTVER_SUFFIX=	${FLAVOR:S/qt//}
 
 OPTIONS_DEFINE=		DOXYGEN
 OPTIONS_SUB=		YES
diff --git a/devel/libdbusmenu-qt/distinfo b/devel/libdbusmenu-qt/distinfo
index e0fc925e78ee..fc6c8564b053 100644
--- a/devel/libdbusmenu-qt/distinfo
+++ b/devel/libdbusmenu-qt/distinfo
@@ -1,3 +1,5 @@
-TIMESTAMP = 1473885294
+TIMESTAMP = 1661237412
 SHA256 (libdbusmenu-qt_0.9.3+16.04.20160218.orig.tar.gz) = a8e6358a31c44ccdf1bfc46c95a77a6bfc7fc1f536aadb913ed4f4405c570cf6
 SIZE (libdbusmenu-qt_0.9.3+16.04.20160218.orig.tar.gz) = 46438
+SHA256 (libdbusmenu-qt6-cmake.patch) = 0d516cc3cfdc6d9fd810b32bfbc75804d94a89ab74af215866cefdbcbff2c19a
+SIZE (libdbusmenu-qt6-cmake.patch) = 197709
diff --git a/devel/libdbusmenu-qt/files/patch-CMakeLists.txt b/devel/libdbusmenu-qt/files/patch-CMakeLists.txt
deleted file mode 100644
index 878a24e76e65..000000000000
--- a/devel/libdbusmenu-qt/files/patch-CMakeLists.txt
+++ /dev/null
@@ -1,20 +0,0 @@
---- CMakeLists.txt
-+++ CMakeLists.txt
-@@ -86,7 +86,7 @@ add_dependencies(distcheck dist)
- configure_file(dbusmenu-qt.pc.in ${CMAKE_BINARY_DIR}/dbusmenu-${QT_SUFFIX}.pc @ONLY)
- 
- install(FILES ${CMAKE_BINARY_DIR}/dbusmenu-${QT_SUFFIX}.pc
--        DESTINATION ${LIB_DESTINATION}/pkgconfig
-+        DESTINATION libdata/pkgconfig
-     )
- 
- add_subdirectory(src)
-@@ -103,7 +106,7 @@ if(WITH_DOC)
-         )
- 
-     install(DIRECTORY ${CMAKE_BINARY_DIR}/html/
--        DESTINATION share/doc/libdbusmenu-${QT_SUFFIX}-doc
-+        DESTINATION share/doc/libdbusmenu-${QT_SUFFIX}
-         )
- endif(WITH_DOC)
- 
diff --git a/devel/libdbusmenu-qt/files/patch-qt6-support b/devel/libdbusmenu-qt/files/patch-qt6-support
new file mode 100644
index 000000000000..5765550a40f9
--- /dev/null
+++ b/devel/libdbusmenu-qt/files/patch-qt6-support
@@ -0,0 +1,253 @@
+--- CMakeLists.txt.orig	2016-02-18 10:13:58 UTC
++++ CMakeLists.txt
+@@ -25,7 +25,7 @@ set(dbusmenu_qt_lib_VERSION ${dbusmenu_qt_lib_SOVERSIO
+ set(dbusmenu_qt_lib_VERSION ${dbusmenu_qt_lib_SOVERSION}.${dbusmenu_qt_lib_API_VERSION}.${dbusmenu_qt_lib_PATCH_VERSION})
+ 
+ # Check if we want to explicitly select the Qt version to be used or autodetect
+-if (NOT USE_QT4 AND NOT USE_QT5)
++if (NOT USE_QT4 AND NOT USE_QT5 AND NOT USE_QT6)
+     # Autodetect, prefering Qt5
+     message(STATUS "Autodetecting Qt version to use")
+     find_package(Qt5Widgets QUIET)
+@@ -35,7 +35,15 @@ endif()
+ endif()
+ 
+ # Detect for which Qt version we're building
+-if (USE_QT5)
++if (USE_QT6)
++    find_package(Qt6 REQUIRED COMPONENTS Core Widgets DBus)
++    include_directories(${Qt5Widgets_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS})
++    set(CMAKE_AUTOMOC ON)
++    set(CMAKE_AUTOMOC_RELAXED_MODE ON)
++    set(CMAKE_POSITION_INDEPENDENT_CODE ON)
++
++    set(QT_SUFFIX "qt6")
++elseif (USE_QT5)
+     find_package(Qt5Widgets REQUIRED)
+     find_package(Qt5DBus REQUIRED)
+     include_directories(${Qt5Widgets_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS})
+@@ -69,9 +77,9 @@ endif (__DBUSMENU_HAVE_W_OVERLOADED_VIRTUAL)
+     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual")
+ endif (__DBUSMENU_HAVE_W_OVERLOADED_VIRTUAL)
+ 
+-check_cxx_compiler_flag(-std=c++11 __DBUSMENU_HAVE_CXX11)
++check_cxx_compiler_flag(-std=c++17 __DBUSMENU_HAVE_CXX11)
+ if (__DBUSMENU_HAVE_CXX11)
+-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
++    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
+ endif (__DBUSMENU_HAVE_CXX11)
+ 
+ include(CMakePackageConfigHelpers)
+@@ -103,12 +111,10 @@ install(FILES ${CMAKE_BINARY_DIR}/dbusmenu-${QT_SUFFIX
+ configure_file(dbusmenu-qt.pc.in ${CMAKE_BINARY_DIR}/dbusmenu-${QT_SUFFIX}.pc @ONLY)
+ 
+ install(FILES ${CMAKE_BINARY_DIR}/dbusmenu-${QT_SUFFIX}.pc
+-        DESTINATION ${LIB_DESTINATION}/pkgconfig
++        DESTINATION libdata/pkgconfig
+     )
+ 
+ add_subdirectory(src)
+-add_subdirectory(tests)
+-add_subdirectory(tools)
+ 
+ if(WITH_DOC)
+     configure_file(Doxyfile.in ${CMAKE_BINARY_DIR}/Doxyfile @ONLY)
+@@ -118,7 +124,7 @@ if(WITH_DOC)
+         )
+ 
+     install(DIRECTORY ${CMAKE_BINARY_DIR}/html/
+-        DESTINATION share/doc/libdbusmenu-${QT_SUFFIX}-doc
++        DESTINATION share/doc/libdbusmenu-${QT_SUFFIX}
+         )
+ endif(WITH_DOC)
+ 
+--- src/CMakeLists.txt.orig	2016-02-18 10:13:58 UTC
++++ src/CMakeLists.txt
+@@ -21,20 +21,23 @@ endif (__DBUSMENU_HAVE_W_ALL)
+     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
+ endif (__DBUSMENU_HAVE_W_ALL)
+ 
+-check_cxx_compiler_flag(-std=c++11 __DBUSMENU_HAVE_CXX11)
++check_cxx_compiler_flag(-std=c++17 __DBUSMENU_HAVE_CXX11)
+ if (__DBUSMENU_HAVE_CXX11)
+-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
++    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
+ endif (__DBUSMENU_HAVE_CXX11)
+ 
+ # Check whether QIcon::name() exists. It was added in late Qt 4.7 cycle, and is
+ # not present in betas.
+ 
+-if (NOT USE_QT5)
++if (NOT USE_QT5 AND NOT USE_QT6)
+     set(CMAKE_REQUIRED_INCLUDES "${QT_INCLUDE_DIR}")
+     set(CMAKE_REQUIRED_LIBRARIES "${QT_QTGUI_LIBRARIES};${QT_QTCORE_LIBRARIES}")
+-else()
++elseif(USE_QT5)
+     set(CMAKE_REQUIRED_INCLUDES "${Qt5Gui_INCLUDE_DIRS};${Qt5Core_INCLUDE_DIRS}")
+     set(CMAKE_REQUIRED_LIBRARIES "${Qt5Gui_LIBRARIES};${Qt5Core_LIBRARIES}")
++else()
++    set(CMAKE_REQUIRED_INCLUDES "${Qt6Gui_INCLUDE_DIRS};${Qt6Core_INCLUDE_DIRS}")
++    set(CMAKE_REQUIRED_LIBRARIES "${Qt6Gui_LIBRARIES};${Qt6Core_LIBRARIES}")
+ endif()
+ check_cxx_source_compiles("
+ #include <QtGui/QIcon>
+@@ -64,17 +67,22 @@ include_directories(
+     ${CMAKE_BINARY_DIR}/src
+     )
+ 
+-if (NOT USE_QT5)
++if (NOT USE_QT5 AND NOT USE_QT6)
+     qt4_automoc(${dbusmenu_qt_SRCS})
+     qt4_add_dbus_adaptor(dbusmenu_qt_SRCS
+         ${CMAKE_CURRENT_SOURCE_DIR}/com.canonical.dbusmenu.xml
+         ${CMAKE_CURRENT_SOURCE_DIR}/dbusmenuexporterdbus_p.h DBusMenuExporterDBus
+         )
+-else()
++elseif(USE_QT5)
+     qt5_add_dbus_adaptor(dbusmenu_qt_SRCS
+         ${CMAKE_CURRENT_SOURCE_DIR}/com.canonical.dbusmenu.xml
+         ${CMAKE_CURRENT_SOURCE_DIR}/dbusmenuexporterdbus_p.h DBusMenuExporterDBus
+         )
++else()
++    qt6_add_dbus_adaptor(dbusmenu_qt_SRCS
++        ${CMAKE_CURRENT_SOURCE_DIR}/com.canonical.dbusmenu.xml
++        ${CMAKE_CURRENT_SOURCE_DIR}/dbusmenuexporterdbus_p.h DBusMenuExporterDBus
++        )
+ endif()
+ 
+ configure_file(dbusmenu_version.h.in
+@@ -88,7 +96,7 @@ set_target_properties(dbusmenu-${QT_SUFFIX} PROPERTIES
+     )
+ 
+ 
+-if (NOT USE_QT5)
++if (NOT USE_QT5 AND NOT USE_QT6)
+     target_link_libraries(dbusmenu-${QT_SUFFIX}
+         ${QT_QTGUI_LIBRARIES}
+         ${QT_QTDBUS_LIBRARIES}
+@@ -96,10 +104,10 @@ else()
+         )
+ else()
+     target_link_libraries(dbusmenu-${QT_SUFFIX}
+-        ${Qt5Gui_LIBRARIES}
+-        ${Qt5Core_LIBRARIES}
+-        ${Qt5DBus_LIBRARIES}
+-        ${Qt5Widgets_LIBRARIES}
++        Qt::Gui
++        Qt::Core
++        Qt::DBus
++        Qt::Widgets
+         )
+ endif()
+ 
+--- tests/CMakeLists.txt.orig	2016-02-18 10:13:58 UTC
++++ tests/CMakeLists.txt
+@@ -1,9 +1,9 @@
+-if (NOT USE_QT5)
++if (NOT USE_QT5 AND NOT USE_QT6)
+     qt4_automoc(slowmenu.cpp)
+ endif()
+ add_executable(slowmenu slowmenu.cpp)
+ 
+-if (NOT USE_QT5)
++if (NOT USE_QT5 AND NOT USE_QT6)
+     target_link_libraries(slowmenu
+         ${QT_QTGUI_LIBRARIES}
+         ${QT_QTDBUS_LIBRARIES}
+@@ -26,7 +26,7 @@ if (NOT USE_QT5)
+         ${QT_QTTEST_INCLUDE_DIR}
+         ${QT_QTDBUS_INCLUDE_DIR}
+         )
+-else()
++elseif(USE_QT5)
+     find_package(Qt5Test REQUIRED)
+ 
+     target_link_libraries(slowmenu
+@@ -51,6 +51,31 @@ else()
+         ${Qt5Test_INCLUDE_DIRS}
+         ${Qt5DBus_INCLUDE_DIRS}
+         )
++else()
++    find_package(Qt6Test REQUIRED)
++
++    target_link_libraries(slowmenu
++        ${Qt6Gui_LIBRARIES}
++        ${Qt6Core_LIBRARIES}
++        ${Qt6DBus_LIBRARIES}
++        dbusmenu-qt6
++    )
++
++    set(test_LIBRARIES
++        ${Qt6Gui_LIBRARIES}
++        ${Qt6Core_LIBRARIES}
++        ${Qt6DBus_LIBRARIES}
++        ${Qt6Test_LIBRARIES}
++        dbusmenu-qt6
++    )
++
++    include_directories(
++        ${CMAKE_CURRENT_SOURCE_DIR}/../src
++        ${CMAKE_CURRENT_BINARY_DIR}/../src
++        ${CMAKE_CURRENT_BINARY_DIR}
++        ${Qt6Test_INCLUDE_DIRS}
++        ${Qt6DBus_INCLUDE_DIRS}
++        )
+ endif()
+ 
+ # Macros to create "check" target
+@@ -77,7 +102,7 @@ set(dbusmenuexportertest_SRCS
+     testutils.cpp
+     )
+ 
+-if (NOT USE_QT5)
++if (NOT USE_QT5 AND NOT USE_QT6)
+     qt4_automoc(${dbusmenuexportertest_SRCS})
+ endif()
+ 
+@@ -94,7 +119,7 @@ set(dbusmenuimportertest_SRCS
+     testutils.cpp
+     )
+ 
+-if (NOT USE_QT5)
++if (NOT USE_QT5 AND NOT USE_QT6)
+     qt4_automoc(${dbusmenuimportertest_SRCS})
+ endif()
+ 
+@@ -110,7 +135,7 @@ set(dbusmenushortcuttest_SRCS
+     dbusmenushortcuttest.cpp
+     )
+ 
+-if (NOT USE_QT5)
++if (NOT USE_QT5 AND NOT USE_QT6)
+     qt4_automoc(${dbusmenushortcuttest_SRCS})
+ endif()
+ 
+--- src/dbusmenuexporter.cpp.orig	2022-08-23 07:04:07 UTC
++++ src/dbusmenuexporter.cpp
+@@ -29,6 +29,7 @@
+ #include <QTimer>
+ #include <QToolButton>
+ #include <QWidgetAction>
++#include <QActionGroup>
+ 
+ // Local
+ #include "dbusmenu_config.h"
+@@ -484,7 +485,7 @@ void DBusMenuExporter::activateAction(QAction *action)
+ {
+     int id = d->idForAction(action);
+     DMRETURN_IF_FAIL(id >= 0);
+-    uint timeStamp = QDateTime::currentDateTime().toTime_t();
++    uint timeStamp = QDateTime::currentDateTime().toSecsSinceEpoch();
+     d->m_dbusObject->ItemActivationRequested(id, timeStamp);
+ }
+ 
+--- src/dbusmenuimporter.cpp.orig	2022-08-23 07:00:03 UTC
++++ src/dbusmenuimporter.cpp
+@@ -34,6 +34,7 @@
+ #include <QTimer>
+ #include <QToolButton>
+ #include <QWidgetAction>
++#include <QActionGroup>
+ 
+ // Local
+ #include "dbusmenutypes_p.h"