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

Qt6 support status #27

Open
ZhongYic00 opened this issue Jul 18, 2024 · 1 comment
Open

Qt6 support status #27

ZhongYic00 opened this issue Jul 18, 2024 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@ZhongYic00
Copy link

ZhongYic00 commented Jul 18, 2024

The plugin needs to be compiled against app's Qt version. I'm idiot on cmake, yet I modified a version that works under my distro.
May help someone wants it on Qt6, hope official support

cmake_minimum_required(VERSION 3.5)  # lowest version tried

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# make release build, if not specified
# (from https://blog.kitware.com/cmake-and-the-default-build-type/)
set(default_build_type "RelWithDebInfo")

if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
  set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Build type" FORCE)
  set_property(
    CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
    "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif ()

# compiler flags
# TODO: separate GCC and Clang warnings; add more
set(
  CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
  -Wall \
  -Wextra \
  -Wshadow \
  -Wformat-nonliteral \
  -Wformat-security \
  -Wnon-virtual-dtor \
  ")

set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og")

set(sanitizer_flags "-fsanitize=address -fsanitize=undefined")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${sanitizer_flags}")
set(CMAKE_MODULE_LINKER_FLAGS_DEBUG
    "${CMAKE_MODULE_LINKER_FLAGS_DEBUG} ${sanitizer_flags}")

#
# third-party libs
#

# qt
find_package(Qt6 COMPONENTS Core Gui REQUIRED)
add_definitions(-DQT_NO_KEYWORDS)
set(CMAKE_AUTOMOC ON)

# libheif
find_package(PkgConfig)
pkg_check_modules(libheif REQUIRED libheif>=1.1)

#
# project source
#

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(sources main.cpp qheifhandler.cpp)

add_library(qheif MODULE ${sources})

target_link_libraries(
  qheif
  PRIVATE
  Qt6::Gui
  ${libheif_LIBRARIES}
)

#
# installation
#

# Use qmake to find plugin dir (adapted from lxqt-qtplugin)
#get_target_property(
#  QT_QMAKE_EXECUTABLE ${Qt6Core_QMAKE_EXECUTABLE} IMPORTED_LOCATION)
set(QT_QMAKE_EXECUTABLE /usr/bin/qmake6)

if (NOT QT_QMAKE_EXECUTABLE)
  message(FATAL_ERROR "qmake is not found.")
endif ()

execute_process(
  COMMAND ${QT_QMAKE_EXECUTABLE} -query QT_INSTALL_PLUGINS
  OUTPUT_VARIABLE QT_PLUGINS_DIR
  OUTPUT_STRIP_TRAILING_WHITESPACE)

if (QT_PLUGINS_DIR)
  message(STATUS "Qt6 plugin directory: " "${QT_PLUGINS_DIR}")
else ()
  message(FATAL_ERROR "Qt6 plugin directory cannot be detected.")
endif ()

# Prefix with DESTDIR if available to allow packaging
if (ENV{DESTDIR} AND NOT ENV{DESTDIR} STREQUAL "")
  set(plugins_dir "$ENV{DESTDIR}${QT_PLUGINS_DIR}")
else ()
  set(plugins_dir "${QT_PLUGINS_DIR}")
endif ()

install(
  TARGETS qheif
  LIBRARY DESTINATION "${plugins_dir}/imageformats")

# vim:sw=2
@jakar jakar added enhancement New feature or request help wanted Extra attention is needed labels Jul 18, 2024
@jakar
Copy link
Owner

jakar commented Jul 18, 2024

Could you make a PR for this? Also (for anyone else reading this), could somebody volunteer to test it, to make sure it still works with both Qt5 and Qt6?

I'm really dropping the ball on maintaining this project, on all fronts. I'm so sorry, everyone. I keep thinking I'll get free time someday, but I only get less as I get older.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants