Skip to content

Commit

Permalink
[dolphin] Adjust CMake to handle the presence of KF6
Browse files Browse the repository at this point in the history
Now if KF6 KIO is present, we build the Dolphin plugin against the Qt6
version of everything. Otherwise we keep assuming the Qt5 version of the
platform.

Signed-off-by: Kevin Ottens <ervin@kde.org>
  • Loading branch information
er-vin committed Mar 6, 2024
1 parent c03837e commit 38b59a8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
7 changes: 4 additions & 3 deletions shell_integration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ if( UNIX AND NOT APPLE )
endif()

if(BUILD_SHELL_INTEGRATION_DOLPHIN)
find_package(KF5KIO "5.16")
if(KF5KIO_FOUND)
find_package(KF5KIO "5.16" CONFIG QUIET)
find_package(KF6KIO "5.240" CONFIG QUIET)
if(KF5KIO_FOUND OR KF6KIO_FOUND)
add_subdirectory(dolphin)
else()
message("Dolphin plugin disabled: KDE Frameworks 5.16 not found")
message("Dolphin plugin disabled: KDE Frameworks 5 and 6 not found")
endif()
endif()
endif()
Expand Down
37 changes: 25 additions & 12 deletions shell_integration/dolphin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,28 @@ project(dolphin-owncloud)

cmake_minimum_required(VERSION 3.16)

set(QT_MIN_VERSION "5.15.0")
set(KF5_MIN_VERSION "5.16.0")
if(KF6KIO_FOUND)
set(QT_MAJOR_VERSION "6")
set(QT_MIN_VERSION "6.6.0")
set(KF_MIN_VERSION "5.240.0")
else()
set(QT_MAJOR_VERSION "5")
set(QT_MIN_VERSION "5.15.0")
set(KF_MIN_VERSION "5.16.0")
endif()

set(KDE_INSTALL_USE_QT_SYS_PATHS ON CACHE BOOL "Install the plugin in the right directory")

find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Core Network)
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Core Network)

find_package(ECM ${KF5_MIN_VERSION} REQUIRED CONFIG)
find_package(ECM ${KF_MIN_VERSION} REQUIRED CONFIG)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})

find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS CoreAddons KIO)
find_package(KF${QT_MAJOR_VERSION} ${KF_MIN_VERSION} REQUIRED COMPONENTS CoreAddons KIO)

set(KDE_INSTALL_DIRS_NO_DEPRECATED TRUE)
include(KDEInstallDirs)
# Before KF5 5.54, kcoreaddons_add_plugin uses deprecated VAR PLUGIN_INSTALL_DIR
# Before KF${QT_MAJOR_VERSION} 5.54, kcoreaddons_add_plugin uses deprecated VAR PLUGIN_INSTALL_DIR
# when that is fixed and you want to remove this workaround,
# you need to _require_ the new enough kcoreaddons
set(PLUGIN_INSTALL_DIR "${KDE_INSTALL_PLUGINDIR}")
Expand All @@ -29,19 +37,24 @@ set(OWNCLOUDDOLPHINHELPER ${APPLICATION_EXECUTABLE}dolphinpluginhelper)
add_library(${OWNCLOUDDOLPHINHELPER} SHARED
ownclouddolphinpluginhelper.h
ownclouddolphinpluginhelper.cpp)
target_link_libraries(${OWNCLOUDDOLPHINHELPER} Qt5::Network)
target_link_libraries(${OWNCLOUDDOLPHINHELPER} Qt${QT_MAJOR_VERSION}::Network)
generate_export_header(${OWNCLOUDDOLPHINHELPER} BASE_NAME ownclouddolphinpluginhelper)
install(TARGETS ${OWNCLOUDDOLPHINHELPER} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})

#---OVERLAY PLUGIN---
set(OWNCLOUDDOLPHINOVERLAYPLUGIN ${APPLICATION_EXECUTABLE}dolphinoverlayplugin)
kcoreaddons_add_plugin(${OWNCLOUDDOLPHINOVERLAYPLUGIN} INSTALL_NAMESPACE "kf5/overlayicon"
JSON ownclouddolphinoverlayplugin.json SOURCES ownclouddolphinoverlayplugin.cpp)
target_link_libraries(${OWNCLOUDDOLPHINOVERLAYPLUGIN} KF5::CoreAddons KF5::KIOCore KF5::KIOWidgets ${OWNCLOUDDOLPHINHELPER})
if(KF6KIO_FOUND)
kcoreaddons_add_plugin(${OWNCLOUDDOLPHINOVERLAYPLUGIN} INSTALL_NAMESPACE "kf${QT_MAJOR_VERSION}/overlayicon"
SOURCES ownclouddolphinoverlayplugin.cpp)
else()
kcoreaddons_add_plugin(${OWNCLOUDDOLPHINOVERLAYPLUGIN} INSTALL_NAMESPACE "kf${QT_MAJOR_VERSION}/overlayicon"
JSON ownclouddolphinoverlayplugin.json SOURCES ownclouddolphinoverlayplugin.cpp)
endif()
target_link_libraries(${OWNCLOUDDOLPHINOVERLAYPLUGIN} KF${QT_MAJOR_VERSION}::CoreAddons KF${QT_MAJOR_VERSION}::KIOCore KF${QT_MAJOR_VERSION}::KIOWidgets ${OWNCLOUDDOLPHINHELPER})

#---ACTION PLUGIN---
set(OWNCLOUDDOLPHINACTIONPLUGIN ${APPLICATION_EXECUTABLE}dolphinactionplugin)
configure_file(ownclouddolphinactionplugin.json.in ${OWNCLOUDDOLPHINACTIONPLUGIN}.json ESCAPE_QUOTES @ONLY)
kcoreaddons_add_plugin(${OWNCLOUDDOLPHINACTIONPLUGIN} INSTALL_NAMESPACE "kf5/kfileitemaction"
kcoreaddons_add_plugin(${OWNCLOUDDOLPHINACTIONPLUGIN} INSTALL_NAMESPACE "kf${QT_MAJOR_VERSION}/kfileitemaction"
SOURCES ownclouddolphinactionplugin.cpp)
target_link_libraries(${OWNCLOUDDOLPHINACTIONPLUGIN} KF5::CoreAddons KF5::KIOCore KF5::KIOWidgets ${OWNCLOUDDOLPHINHELPER})
target_link_libraries(${OWNCLOUDDOLPHINACTIONPLUGIN} KF${QT_MAJOR_VERSION}::CoreAddons KF${QT_MAJOR_VERSION}::KIOCore KF${QT_MAJOR_VERSION}::KIOWidgets ${OWNCLOUDDOLPHINHELPER})

0 comments on commit 38b59a8

Please sign in to comment.