Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qt-GTK3 - attempt at creating distinct package for platform plugins #22086

Merged
merged 1 commit into from
Mar 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions recipes/qt-gtk-platformtheme/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
set -ex

# This creates a standalone shared library that mimics the results
# of configuring qt with the flag `-gtk`
#
# By creating this standalone package, we simplify the proces of
# rebuilding qt due to requiring fewer dependencies for the main package
# requiring fewer bumps when the version changes.
# The CMakeLists.txt file was inspired by the one from Fedora
# https://github.com/FedoraQt/QGnomePlatform
# and is likely to work for qt6
cp -R src/plugins/platformthemes/gtk3/ qgtk3
cd qgtk3
cp ${RECIPE_DIR}/gtk_theme_CMakeLists.txt CMakeLists.txt

mkdir -p build
cd build

cmake ${CMAKE_ARGS} \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_PREFIX_PATH=${PREFIX} \
..

make -j${CPU_COUNT}
make install
72 changes: 72 additions & 0 deletions recipes/qt-gtk-platformtheme/gtk_theme_CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
project(QtGTKPlatformTheme)

cmake_minimum_required(VERSION 3.16)

option(USE_QT6 "Use Qt6 instead of Qt5" OFF)

if (USE_QT6)
set(QT_MIN_VERSION "6.2.0")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(QT_VERSION_MAJOR "6")
else()
set(QT_MIN_VERSION "5.15.2")
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(QT_VERSION_MAJOR "5")
endif()

find_package(Qt${QT_VERSION_MAJOR} ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
Core
DBus
Gui
Widgets
ThemeSupport
)

if (NOT QT_PLUGINS_DIR)
if (NOT USE_QT6)
get_target_property(REAL_QMAKE_EXECUTABLE ${Qt5Core_QMAKE_EXECUTABLE}
IMPORTED_LOCATION)
execute_process(COMMAND "${REAL_QMAKE_EXECUTABLE}" -query QT_INSTALL_PLUGINS
OUTPUT_VARIABLE QT_PLUGINS_DIR
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
set(QT_PLUGINS_DIR ${QT6_INSTALL_PLUGINS})
endif()
endif()

find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK+3 REQUIRED IMPORTED_TARGET gtk+-3.0)


find_package(X11 REQUIRED)

set(gtk_theme_SRCS
main.cpp
qgtk3dialoghelpers.cpp
qgtk3dialoghelpers.h
qgtk3menu.cpp
qgtk3menu.h
qgtk3theme.cpp
qgtk3theme.h
)

add_library(qgtk3 MODULE ${gtk_theme_SRCS})
target_compile_definitions(qgtk3 PRIVATE -DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_6)

target_link_libraries(qgtk3
PkgConfig::GTK+3
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::CorePrivate
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::GuiPrivate
)

if (NOT USE_QT6)
target_link_libraries(qgtk3 Qt5::ThemeSupportPrivate)
endif()
set_property(TARGET qgtk3 PROPERTY AUTOMOC ON)

install(TARGETS qgtk3 DESTINATION ${QT_PLUGINS_DIR}/platformthemes)

68 changes: 68 additions & 0 deletions recipes/qt-gtk-platformtheme/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{% set version = "5.15.8" %}

package:
name: qt-gtk-platformtheme
version: {{ version }}

source:
# We only need to download the smaller qt-base, not qt-main for this plugin
url: https://download.qt.io/official_releases/qt/{{ version.rpartition('.')[0] }}/{{ version }}/submodules/qtbase-everywhere-opensource-src-{{ version }}.tar.xz
sha256: bfb11126c7f3abc3fdf86425ce912988b864a7e79a606d77325cffdbacb4be9c # 5.15.8

build:
number: 0
skip: true # [not linux]
detect_binary_files_with_prefix: true
run_exports:
- {{ pin_subpackage('qt-gtk-platformtheme', max_pin='x.x') }}

requirements:
build:
- cmake
- make # [unix]
- jom # [win]
- ninja
- perl
- {{ compiler('cxx') }}
- {{ compiler('c') }}
- qt-main {{ version }} # [build_platform != target_platform]
- sysroot_linux-64 2.17 # [linux]
- {{ cdt('mesa-libgl-devel') }} # [linux]
- {{ cdt('mesa-libegl-devel') }} # [linux]
- {{ cdt('mesa-dri-drivers') }} # [linux]
- {{ cdt('libdrm-devel') }} # [linux]
- {{ cdt('libglvnd-glx') }} # [linux]
- {{ cdt('libglvnd-egl') }} # [linux]
host:
- qt-main {{ version }}
- glib
- gtk3
- pango
- atk
- cairo
- gdk-pixbuf
- xorg-libxinerama
- xorg-libxrandr
- xorg-libxcursor
- xorg-libxcomposite
- xorg-libxdamage
- xorg-xineramaproto
run:
# We want to be pinned to the exact qt version
- qt-main {{ version }}

test:
commands:
- test -f "${PREFIX}/plugins/platformthemes/libqgtk3${SHLIB_EXT}"

about:
home: http://qt-project.org
license: LGPL-3.0-only
license_file: LICENSE.LGPLv3
summary: Qt GTK3 platform theme
dev_url: https://github.com/qt/qtbase/tree/5.15/src/plugins/platformthemes/gtk3


extra:
recipe-maintainers:
- conda-forge/qt-main