Add KF6/Qt6 build support with auto-detection
CMakeLists.txt now probes for KF6TextEditor first, falls back to KF5. Uses correct install namespace (kf6/ktexteditor vs ktexteditor). Source code already had the necessary #if guards for KF6 constructor. No API changes needed - KTextEditor plugin interface is identical.
This commit is contained in:
parent
ab2d531240
commit
163c3d18a9
|
|
@ -5,30 +5,55 @@ set(CMAKE_CXX_STANDARD 17)
|
|||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
||||
find_package(ECM REQUIRED NO_MODULE)
|
||||
find_package(ECM 5.80 REQUIRED NO_MODULE)
|
||||
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
|
||||
|
||||
# Probe for KF6 before including KDE macros (which need QT_MAJOR_VERSION)
|
||||
find_package(KF6TextEditor QUIET CONFIG)
|
||||
if(KF6TextEditor_FOUND)
|
||||
set(QT_MAJOR_VERSION 6)
|
||||
else()
|
||||
set(QT_MAJOR_VERSION 5)
|
||||
endif()
|
||||
|
||||
include(KDEInstallDirs)
|
||||
include(KDECMakeSettings)
|
||||
include(KDECompilerSettings NO_POLICY_SCOPE)
|
||||
|
||||
find_package(Qt5 REQUIRED COMPONENTS Core Widgets)
|
||||
find_package(KF5TextEditor REQUIRED)
|
||||
find_package(KF5I18n REQUIRED)
|
||||
find_package(KF5CoreAddons REQUIRED)
|
||||
if(QT_MAJOR_VERSION EQUAL 6)
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core Widgets)
|
||||
find_package(KF6I18n REQUIRED)
|
||||
find_package(KF6CoreAddons REQUIRED)
|
||||
set(KF_LINK_LIBS
|
||||
KF6::TextEditor
|
||||
KF6::I18n
|
||||
Qt6::Core
|
||||
Qt6::Widgets
|
||||
)
|
||||
set(PLUGIN_INSTALL_NS "kf6/ktexteditor")
|
||||
message(STATUS "Building Git++ with KF6/Qt6")
|
||||
else()
|
||||
find_package(Qt5 REQUIRED COMPONENTS Core Widgets)
|
||||
find_package(KF5TextEditor REQUIRED)
|
||||
find_package(KF5I18n REQUIRED)
|
||||
find_package(KF5CoreAddons REQUIRED)
|
||||
set(KF_LINK_LIBS
|
||||
KF5::TextEditor
|
||||
KF5::I18n
|
||||
Qt5::Core
|
||||
Qt5::Widgets
|
||||
)
|
||||
set(PLUGIN_INSTALL_NS "ktexteditor")
|
||||
message(STATUS "Building Git++ with KF5/Qt5")
|
||||
endif()
|
||||
|
||||
kcoreaddons_add_plugin(gitplusplus
|
||||
SOURCES
|
||||
gitplusplus.cpp
|
||||
gitstatusmodel.cpp
|
||||
INSTALL_NAMESPACE "ktexteditor"
|
||||
INSTALL_NAMESPACE "${PLUGIN_INSTALL_NS}"
|
||||
)
|
||||
|
||||
target_link_libraries(gitplusplus
|
||||
KF5::TextEditor
|
||||
KF5::I18n
|
||||
Qt5::Core
|
||||
Qt5::Widgets
|
||||
)
|
||||
target_link_libraries(gitplusplus ${KF_LINK_LIBS})
|
||||
|
||||
target_include_directories(gitplusplus PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
|
|
|||
7
Makefile
7
Makefile
|
|
@ -2,11 +2,12 @@
|
|||
|
||||
BUILD_DIR := build
|
||||
|
||||
all: $(BUILD_DIR)/gitplusplus.so
|
||||
all: $(BUILD_DIR)/Makefile
|
||||
@cd $(BUILD_DIR) && make -j$$(nproc)
|
||||
|
||||
$(BUILD_DIR)/gitplusplus.so: gitplusplus.cpp gitplusplus.h gitprocess.h gitstatusmodel.cpp gitstatusmodel.h metadata.json
|
||||
$(BUILD_DIR)/Makefile: CMakeLists.txt
|
||||
@mkdir -p $(BUILD_DIR)
|
||||
@cd $(BUILD_DIR) && cmake .. -DCMAKE_INSTALL_PREFIX=/usr -Wno-dev 2>/dev/null && make -j$$(nproc)
|
||||
@cd $(BUILD_DIR) && cmake .. -DCMAKE_INSTALL_PREFIX=/usr -Wno-dev
|
||||
|
||||
install: all
|
||||
cd $(BUILD_DIR) && sudo make install
|
||||
|
|
|
|||
16
README.md
16
README.md
|
|
@ -105,7 +105,13 @@ for file listing, so the file tree shows exactly what git tracks.
|
|||
|
||||
## Building
|
||||
|
||||
Requires KF5 (or KF6) development packages:
|
||||
Supports both KF5 (Kate on Qt5) and KF6 (Kate on Qt6). The build system
|
||||
auto-detects which framework is available, preferring KF6.
|
||||
|
||||
**Dependencies** (install the set matching your Kate version):
|
||||
|
||||
- KF6: `libkf6texteditor-dev`, `libkf6i18n-dev`, `libkf6coreaddons-dev`, `qt6-base-dev`, `extra-cmake-modules`
|
||||
- KF5: `libkf5texteditor-dev`, `libkf5i18n-dev`, `libkf5coreaddons-dev`, `qtbase5-dev`, `extra-cmake-modules`
|
||||
|
||||
```sh
|
||||
mkdir build && cd build
|
||||
|
|
@ -123,9 +129,11 @@ make install
|
|||
## Installation Path
|
||||
|
||||
The plugin installs to Kate's KTextEditor plugin directory:
|
||||
```
|
||||
/usr/lib/x86_64-linux-gnu/qt5/plugins/ktexteditor/gitplusplus.so
|
||||
```
|
||||
|
||||
- KF6: `/usr/lib64/qt6/plugins/kf6/ktexteditor/gitplusplus.so`
|
||||
- KF5: `/usr/lib/x86_64-linux-gnu/qt5/plugins/ktexteditor/gitplusplus.so`
|
||||
|
||||
The exact path depends on your distribution's library layout.
|
||||
|
||||
Enable it in Kate → Settings → Configure Kate → Plugins → "Git++".
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue