Skip to content

Commit

Permalink
CMake: Add QPA Platform interface as optional component
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaski committed Jan 25, 2025
1 parent a683a27 commit 69f001a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 24 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ jobs:
hicolor-icon-theme
qt6-core-devel
qt6-gui-devel
qt6-gui-private-devel
qt6-widgets-devel
qt6-concurrent-devel
qt6-network-devel
Expand Down Expand Up @@ -464,7 +465,9 @@ jobs:
libcdio-dev
libmtp-dev
libgpod-dev
libxkbcommon-dev
qt6-base-dev
qt6-base-private-dev
qt6-base-dev-tools
qt6-tools-dev
qt6-tools-dev-tools
Expand Down Expand Up @@ -545,7 +548,9 @@ jobs:
libcdio-dev
libmtp-dev
libgpod-dev
libxkbcommon-dev
qt6-base-dev
qt6-base-private-dev
qt6-base-dev-tools
qt6-tools-dev
qt6-tools-dev-tools
Expand Down
31 changes: 10 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -214,30 +214,19 @@ set(QT_VERSION_MAJOR 6)
set(QT_MIN_VERSION 6.4.0)
set(QT_DEFAULT_MAJOR_VERSION ${QT_VERSION_MAJOR})
set(QT_COMPONENTS Core Concurrent Gui Widgets Network Sql)
set(QT_OPTIONAL_COMPONENTS LinguistTools Test)
set(QT_OPTIONAL_COMPONENTS GuiPrivate LinguistTools Test)
if(UNIX AND NOT APPLE)
list(APPEND QT_OPTIONAL_COMPONENTS DBus)
endif()
set(QT_NO_PRIVATE_MODULE_WARNING ON)

find_package(Qt${QT_VERSION_MAJOR} ${QT_MIN_VERSION} COMPONENTS ${QT_COMPONENTS} REQUIRED OPTIONAL_COMPONENTS ${QT_OPTIONAL_COMPONENTS})

if(Qt${QT_VERSION_MAJOR}DBus_FOUND)
set(DBUS_FOUND ON)
if(TARGET "Qt${QT_VERSION_MAJOR}::GuiPrivate")
set(QT_GUI_PRIVATE_FOUND ON)
endif()

if(X11_FOUND)

find_path(QPA_QPLATFORMNATIVEINTERFACE_H qpa/qplatformnativeinterface.h PATHS ${Qt${QT_VERSION_MAJOR}Gui_INCLUDE_DIRS} ${Qt${QT_VERSION_MAJOR}Gui_PRIVATE_INCLUDE_DIRS})
if(NOT QPA_QPLATFORMNATIVEINTERFACE_H)
find_path(QPA_QPLATFORMNATIVEINTERFACE_H ${Qt${QT_VERSION_MAJOR}Gui_VERSION}/QtGui/qpa/qplatformnativeinterface.h PATHS ${Qt${QT_VERSION_MAJOR}Gui_INCLUDE_DIRS} ${Qt${QT_VERSION_MAJOR}Gui_PRIVATE_INCLUDE_DIRS})
endif()
if(QPA_QPLATFORMNATIVEINTERFACE_H)
set(HAVE_QPA_QPLATFORMNATIVEINTERFACE_H ON)
message(STATUS "Have qpa/qplatformnativeinterface.h header.")
else()
message(STATUS "Missing qpa/qplatformnativeinterface.h header.")
endif()

# Check for QX11Application (Qt 6 compiled with XCB).
set(CMAKE_REQUIRED_FLAGS "-std=c++17")
set(CMAKE_REQUIRED_LIBRARIES Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui)
Expand All @@ -252,7 +241,6 @@ if(X11_FOUND)
)
unset(CMAKE_REQUIRED_FLAGS)
unset(CMAKE_REQUIRED_LIBRARIES)

endif()

# SingleApplication
Expand Down Expand Up @@ -294,7 +282,7 @@ if(UNIX AND NOT APPLE)
DEPENDS "libpulse" LIBPULSE_FOUND
)
optional_component(DBUS ON "D-Bus support"
DEPENDS "Qt D-Bus" DBUS_FOUND
DEPENDS "Qt D-Bus" Qt${QT_VERSION_MAJOR}DBus_FOUND
)
optional_component(MPRIS2 ON "MPRIS2 D-Bus Interface"
DEPENDS "D-Bus support" HAVE_DBUS
Expand Down Expand Up @@ -375,6 +363,10 @@ if(APPLE OR WIN32)
)
endif()

optional_component(QPA_QPLATFORMNATIVEINTERFACE ON "QPA Platform interface"
DEPENDS "Qt Gui Private" QT_GUI_PRIVATE_FOUND
)

if(HAVE_SONGFINGERPRINTING OR HAVE_MUSICBRAINZ)
set(HAVE_CHROMAPRINT ON)
endif()
Expand Down Expand Up @@ -1502,10 +1494,6 @@ if(SINGLEAPPLICATION_INCLUDE_DIRS)
target_include_directories(strawberry_lib SYSTEM PUBLIC ${SINGLEAPPLICATION_INCLUDE_DIRS})
endif()

if(HAVE_QPA_QPLATFORMNATIVEINTERFACE_H)
target_include_directories(strawberry_lib SYSTEM PUBLIC ${Qt${QT_VERSION_MAJOR}Gui_PRIVATE_INCLUDE_DIRS})
endif()

target_link_libraries(strawberry_lib PUBLIC
${CMAKE_THREAD_LIBS_INIT}
$<$<BOOL:${HAVE_BACKTRACE}>:${Backtrace_LIBRARIES}>
Expand All @@ -1526,6 +1514,7 @@ target_link_libraries(strawberry_lib PUBLIC
Qt${QT_VERSION_MAJOR}::Network
Qt${QT_VERSION_MAJOR}::Sql
$<$<BOOL:${HAVE_DBUS}>:Qt${QT_VERSION_MAJOR}::DBus>
$<$<BOOL:${HAVE_QPA_QPLATFORMNATIVEINTERFACE}>:Qt${QT_VERSION_MAJOR}::GuiPrivate>
ICU::uc
ICU::i18n
$<$<BOOL:${HAVE_ALSA}>:ALSA::ALSA>
Expand Down
2 changes: 1 addition & 1 deletion src/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
#cmakedefine INSTALL_TRANSLATIONS
#define TRANSLATIONS_DIR "${CMAKE_INSTALL_PREFIX}/share/strawberry/translations"

#cmakedefine HAVE_QPA_QPLATFORMNATIVEINTERFACE
#cmakedefine HAVE_QX11APPLICATION
#cmakedefine HAVE_QPA_QPLATFORMNATIVEINTERFACE_H

#cmakedefine ENABLE_WIN32_CONSOLE

Expand Down
4 changes: 2 additions & 2 deletions src/osd/osdpretty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
#include <QFlags>
#include <QtEvents>

#ifdef HAVE_QPA_QPLATFORMNATIVEINTERFACE_H
#ifdef HAVE_QPA_QPLATFORMNATIVEINTERFACE
# include <qpa/qplatformnativeinterface.h>
#endif

Expand Down Expand Up @@ -214,7 +214,7 @@ void OSDPretty::ScreenRemoved(QScreen *screen) {

bool OSDPretty::IsTransparencyAvailable() {

#ifdef HAVE_QPA_QPLATFORMNATIVEINTERFACE_H
#ifdef HAVE_QPA_QPLATFORMNATIVEINTERFACE
if (qApp) {
QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface();
QScreen *screen = popup_screen_ == nullptr ? QGuiApplication::primaryScreen() : popup_screen_;
Expand Down

0 comments on commit 69f001a

Please sign in to comment.