build: install to ~/.local and the Qt plugin dir by default
cmake --install previously defaulted to CMAKE_INSTALL_PREFIX=/usr/local (needs root) and, via KDE_INSTALL_PLUGINDIR, to lib/<arch>/plugins/ — a directory Kate does NOT scan (it scans lib/<arch>/qt6/plugins/, per QT_PLUGIN_PATH). So a plain install both failed on permissions and would have put the plugins where they can't be found. Follow the sibling ollie project's approach instead of hand-rolling path logic: - Default CMAKE_INSTALL_PREFIX to $HOME/.local when the user did not pass one. ECM's KDECMakeSettings resets an unspecified prefix back to /usr/local, so we capture CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT *before* including it and re-apply the user-local default *after*, where it is not clobbered. - Point KDE_INSTALL_PLUGINDIR at QT6_INSTALL_PLUGINS (prefix-relative lib/<arch>/qt6/plugins) so kcoreaddons_add_plugin(INSTALL_NAMESPACE kf6/ktexteditor) lands where Kate looks. Set the *normal* variable (the macro reads it directly; a cache-only FORCE would be shadowed) as well as the cache. Result: `cmake --install build` with no flags installs all six plugins to ~/.local/lib/<arch>/qt6/plugins/kf6/ktexteditor/ with no root. README: replace the manual install -D loop with `cmake --install build`, state clearly that it installs to the home dir by default, show the resulting path, and document --prefix /usr for a system-wide install.
This commit is contained in:
parent
2c41a430b6
commit
29136ac898
|
|
@ -17,6 +17,12 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
|||
"Build type (Debug, Release, RelWithDebInfo, MinSizeRel)" FORCE)
|
||||
endif()
|
||||
|
||||
# Remember whether the user picked an install prefix *before* ECM's
|
||||
# KDECMakeSettings runs: that module resets an unspecified prefix back to
|
||||
# /usr/local, so we cannot rely on CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT
|
||||
# after including it. We re-apply the user-local default below, post-include.
|
||||
set(_deft_prefix_was_default ${CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT})
|
||||
|
||||
find_package(ECM ${KF_MIN_VERSION} REQUIRED NO_MODULE)
|
||||
list(APPEND CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
|
||||
|
||||
|
|
@ -24,12 +30,30 @@ include(KDEInstallDirs)
|
|||
include(KDECMakeSettings)
|
||||
include(KDECompilerSettings NO_POLICY_SCOPE)
|
||||
|
||||
# Default to a user-local install prefix when the user did not pick one. These
|
||||
# are user KTextEditor plugins, not system packages: the stock /usr/local
|
||||
# default needs root and is the wrong place for them. Applied here, after
|
||||
# KDECMakeSettings, so it is not clobbered.
|
||||
if(_deft_prefix_was_default)
|
||||
set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/.local" CACHE PATH "Install prefix" FORCE)
|
||||
endif()
|
||||
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
find_package(Qt6 ${QT_MIN_VERSION} REQUIRED COMPONENTS Core Gui Widgets Concurrent)
|
||||
find_package(Qt6 ${QT_MIN_VERSION} COMPONENTS Test)
|
||||
find_package(KF6 ${KF_MIN_VERSION} COMPONENTS TextEditor XmlGui CoreAddons I18n)
|
||||
|
||||
# KDE's KDE_INSTALL_PLUGINDIR defaults to lib/<arch>/plugins/, but Qt6 plugins
|
||||
# (which is where Kate scans for KTextEditor plugins) live under
|
||||
# lib/<arch>/qt6/plugins/. Point the plugin install base at Qt's own plugin
|
||||
# dir (QT6_INSTALL_PLUGINS is prefix-relative) so
|
||||
# kcoreaddons_add_plugin(INSTALL_NAMESPACE kf6/ktexteditor) lands where Kate
|
||||
# actually looks. kcoreaddons_add_plugin reads the *normal* variable, so set
|
||||
# it directly (not just the cache entry, which the normal value would shadow).
|
||||
set(KDE_INSTALL_PLUGINDIR "${QT6_INSTALL_PLUGINS}")
|
||||
set(KDE_INSTALL_PLUGINDIR "${QT6_INSTALL_PLUGINS}" CACHE PATH "" FORCE)
|
||||
|
||||
enable_testing()
|
||||
|
||||
add_subdirectory(src)
|
||||
|
|
|
|||
25
README.md
25
README.md
|
|
@ -65,13 +65,28 @@ KTextEditor plugins under `build/bin/kf6/ktexteditor/`:
|
|||
| `deft_sam.so` | `[deft:nineify] sam` | `sam`-style structural regular expressions |
|
||||
| `deft_plumb.so` | `[deft:nineify] plumb`| Plan 9 plumber (open under cursor) |
|
||||
|
||||
Drop whichever features you want where Kate scans for KTextEditor plugins (a
|
||||
user path on `QT_PLUGIN_PATH`):
|
||||
Drop whichever features you want where Kate scans for KTextEditor plugins. The
|
||||
simplest way is `cmake --install`, which already targets the right place:
|
||||
|
||||
```sh
|
||||
for so in build/bin/kf6/ktexteditor/deft_*.so; do
|
||||
install -D "$so" ~/.local/lib/x86_64-linux-gnu/qt6/plugins/kf6/ktexteditor/"$(basename "$so")"
|
||||
done
|
||||
cmake --install build
|
||||
```
|
||||
|
||||
**By default this installs into your home directory, not system-wide.** The
|
||||
build sets `CMAKE_INSTALL_PREFIX` to `~/.local` when you don't pass one (these
|
||||
are personal plugins, so installing them under `/usr/local` — the stock CMake
|
||||
default — would need `root` and is the wrong place), and it points the plugin
|
||||
install dir at Qt's own plugin path. So the plugins land at:
|
||||
|
||||
```
|
||||
~/.local/lib/<arch>/qt6/plugins/kf6/ktexteditor/deft_*.so
|
||||
```
|
||||
|
||||
which is exactly the directory Kate scans (`QT_PLUGIN_PATH`). To install
|
||||
system-wide instead, pass an explicit prefix (and expect to need `root`):
|
||||
|
||||
```sh
|
||||
cmake --install build --prefix /usr
|
||||
```
|
||||
|
||||
Then in Kate: Settings → Configure Kate → Plugins → enable each **`[deft:…]`**
|
||||
|
|
|
|||
Loading…
Reference in New Issue