Skip to content

Commit

Permalink
Don't use versionless Qt cmake imports (Issue #57 and #60)
Browse files Browse the repository at this point in the history
I think you can only use them with Qt 5.15 and Kubuntu 20.04 only has
Qt 5.12.
  • Loading branch information
Zren committed Jan 11, 2022
1 parent 435bcfd commit 6e4386c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ include (KDEInstallDirs)
include (KDECMakeSettings)
include (KDECompilerSettings NO_POLICY_SCOPE)

set(QT_MIN_VERSION "5.9.0")
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
# set(QT_MIN_VERSION "5.9.0")
# https://doc.qt.io/qt-6/cmake-qt5-and-qt6-compatibility.html#supporting-older-qt-5-versions
# find_package(QT NAMES Qt6 Qt5)
find_package(QT NAMES Qt5)
# find_package(QT NAMES Qt6)
find_package(Qt${QT_VERSION_MAJOR} CONFIG REQUIRED COMPONENTS
Widgets
DBus
)
Expand Down
31 changes: 26 additions & 5 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
find_package (KDecoration2 REQUIRED)

find_package (Qt5 REQUIRED COMPONENTS
find_package (Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS
Core
Gui
)
Expand Down Expand Up @@ -30,7 +30,16 @@ find_package(XCB MODULE REQUIRED COMPONENTS
)
set_package_properties(XCB PROPERTIES TYPE REQUIRED)

find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS X11Extras)
if (Qt6_FOUND)
# The QX11Info class has been removed.
# Clients that still rely on the functionality can include the private header <QtGui/private/qtx11extras_p.h> as a stopgap solution.
# To enable private headers use QT += gui-private with qmake, or add a project dependency to Qt::GuiPrivate with CMake.
# https://doc.qt.io/qt-6/extras-changes-qt6.html#changes-to-qt-x11-extras
find_package(Qt${QT_VERSION_MAJOR} ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS GuiPrivate)
elseif(Qt5_FOUND)
find_package(Qt${QT_VERSION_MAJOR} ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS X11Extras)
endif()


if(X11_FOUND AND XCB_XCB_FOUND)
set(HAVE_X11 ON)
Expand Down Expand Up @@ -81,9 +90,9 @@ add_library (materialdecoration MODULE
target_link_libraries (materialdecoration
PUBLIC
dbusmenuqt
Qt::Core
Qt::Gui
Qt::X11Extras
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
# Qt${QT_VERSION_MAJOR}::X11Extras
KF5::ConfigCore
KF5::ConfigGui
KF5::ConfigWidgets
Expand All @@ -98,6 +107,18 @@ target_link_libraries (materialdecoration
PRIVATE
KDecoration2::KDecoration
)
if (Qt6_FOUND)
# The QX11Info class has been removed.
target_link_libraries (materialdecoration
PUBLIC
Qt${QT_VERSION_MAJOR}::GuiPrivate
)
elseif(Qt5_FOUND)
target_link_libraries (materialdecoration
PUBLIC
Qt${QT_VERSION_MAJOR}::X11Extras
)
endif()

install (TARGETS materialdecoration
DESTINATION ${PLUGIN_INSTALL_DIR}/org.kde.kdecoration2)
4 changes: 2 additions & 2 deletions src/libdbusmenuqt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ qt_add_dbus_interface(libdbusmenu_SRCS com.canonical.dbusmenu.xml dbusmenu_inter

add_library(dbusmenuqt STATIC ${libdbusmenu_SRCS})
target_link_libraries(dbusmenuqt
Qt::DBus
Qt::Widgets
Qt${QT_VERSION_MAJOR}::DBus
Qt${QT_VERSION_MAJOR}::Widgets
)

add_subdirectory(test)

0 comments on commit 6e4386c

Please sign in to comment.