build: auto-wire QT_PLUGIN_PATH for a user-local install
A home-prefix install puts the plugins outside Qt's default search path, so Kate would not list them until QT_PLUGIN_PATH includes the install dir — the step a bare 'cmake --install' silently left undone. Solve it the way the ollie project does (a Plasma login env snippet), and automate the common case: - Add 99-deft.sh.in, a Plasma env snippet that prepends the install's qt6 plugin dir to QT_PLUGIN_PATH. configure_file() fills in the absolute path. - On a user-local install (prefix inside $HOME), install(CODE) drops the configured 99-deft.sh into ~/.config/plasma-workspace/env/ so the lookup path is wired up with no manual step; Plasma sources it at next login. The installer also prints a one-line export to use the plugins immediately. - On a system-prefix install it does not touch the user's config; it just prints where the plugins went and leaves the ready snippet in the build dir. README: add a 'Making Kate find a user-local install' section explaining that QT_PLUGIN_PATH must include ~/.local, that the installer handles it, and how to activate it in the current session (or a non-Plasma shell). Verified: cmake --install with the default prefix installs the six plugins and writes ~/.config/plasma-workspace/env/99-deft.sh with the correct path.
This commit is contained in:
parent
29136ac898
commit
4325513c47
|
|
@ -0,0 +1,10 @@
|
||||||
|
# Deft — add the user-local KTextEditor plugin directory to Qt's search path.
|
||||||
|
#
|
||||||
|
# Kate/KTextEditor only loads plugins found on QT_PLUGIN_PATH. When Deft is
|
||||||
|
# installed under a user prefix (the default, ~/.local) rather than a system
|
||||||
|
# one, that directory is not searched unless it is added here. Plasma sources
|
||||||
|
# every *.sh in ~/.config/plasma-workspace/env/ at login.
|
||||||
|
#
|
||||||
|
# The path below is filled in at install time with the directory the plugins
|
||||||
|
# were installed into.
|
||||||
|
export QT_PLUGIN_PATH="@DEFT_PLUGIN_PATH@${QT_PLUGIN_PATH:+:$QT_PLUGIN_PATH}"
|
||||||
|
|
@ -54,6 +54,37 @@ find_package(KF6 ${KF_MIN_VERSION} COMPONENTS TextEditor XmlGui CoreAddons I18n)
|
||||||
set(KDE_INSTALL_PLUGINDIR "${QT6_INSTALL_PLUGINS}")
|
set(KDE_INSTALL_PLUGINDIR "${QT6_INSTALL_PLUGINS}")
|
||||||
set(KDE_INSTALL_PLUGINDIR "${QT6_INSTALL_PLUGINS}" CACHE PATH "" FORCE)
|
set(KDE_INSTALL_PLUGINDIR "${QT6_INSTALL_PLUGINS}" CACHE PATH "" FORCE)
|
||||||
|
|
||||||
|
# Qt only searches QT_PLUGIN_PATH for plugins. A user-prefix install (the
|
||||||
|
# default) puts the plugins outside the system search path, so Kate will not
|
||||||
|
# find them until that directory is added to QT_PLUGIN_PATH. Generate a Plasma
|
||||||
|
# login environment snippet that does exactly that, and — for a user-local
|
||||||
|
# install — drop it into ~/.config/plasma-workspace/env/ automatically so the
|
||||||
|
# lookup path is wired up without a manual step. For a system install the user
|
||||||
|
# installs it themselves (printed below); packagers usually don't want it.
|
||||||
|
get_filename_component(DEFT_PLUGIN_PATH
|
||||||
|
"${CMAKE_INSTALL_PREFIX}/${QT6_INSTALL_PLUGINS}" ABSOLUTE)
|
||||||
|
configure_file("${CMAKE_SOURCE_DIR}/99-deft.sh.in"
|
||||||
|
"${CMAKE_BINARY_DIR}/99-deft.sh" @ONLY)
|
||||||
|
|
||||||
|
# Is the chosen prefix inside the user's home (a personal install)?
|
||||||
|
string(FIND "${CMAKE_INSTALL_PREFIX}" "$ENV{HOME}" _deft_prefix_in_home)
|
||||||
|
if(_deft_prefix_in_home EQUAL 0)
|
||||||
|
set(_deft_plasma_env_dir "$ENV{HOME}/.config/plasma-workspace/env")
|
||||||
|
install(CODE "
|
||||||
|
file(MAKE_DIRECTORY \"${_deft_plasma_env_dir}\")
|
||||||
|
file(INSTALL \"${CMAKE_BINARY_DIR}/99-deft.sh\"
|
||||||
|
DESTINATION \"${_deft_plasma_env_dir}\")
|
||||||
|
message(STATUS \"Deft: installed Qt plugin-path snippet to ${_deft_plasma_env_dir}/99-deft.sh\")
|
||||||
|
message(STATUS \"Deft: log out and back in (or run: export QT_PLUGIN_PATH=\\\"${DEFT_PLUGIN_PATH}:\\\$QT_PLUGIN_PATH\\\") so Kate finds the plugins now.\")
|
||||||
|
")
|
||||||
|
else()
|
||||||
|
install(CODE "
|
||||||
|
message(STATUS \"Deft: plugins installed under a system prefix; QT_PLUGIN_PATH already covers it if that prefix is standard.\")
|
||||||
|
message(STATUS \"Deft: if Kate does not list them, add this to the Qt plugin path: ${DEFT_PLUGIN_PATH}\")
|
||||||
|
message(STATUS \"Deft: a ready-made login snippet is at ${CMAKE_BINARY_DIR}/99-deft.sh (copy to ~/.config/plasma-workspace/env/).\")
|
||||||
|
")
|
||||||
|
endif()
|
||||||
|
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|
|
||||||
22
README.md
22
README.md
|
|
@ -89,6 +89,28 @@ system-wide instead, pass an explicit prefix (and expect to need `root`):
|
||||||
cmake --install build --prefix /usr
|
cmake --install build --prefix /usr
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Making Kate find a user-local install
|
||||||
|
|
||||||
|
Qt only loads plugins from directories on **`QT_PLUGIN_PATH`**, and that does
|
||||||
|
*not* include `~/.local` by default — so after a home-directory install Kate
|
||||||
|
will not list the plugins until that path is on the search list. This is a
|
||||||
|
one-time, per-user setup step.
|
||||||
|
|
||||||
|
The install **automates it for you**: when the prefix is inside your home, it
|
||||||
|
writes a login snippet to
|
||||||
|
`~/.config/plasma-workspace/env/99-deft.sh` that adds the plugin directory to
|
||||||
|
`QT_PLUGIN_PATH`. Plasma sources it at login, so after the next **log out / log
|
||||||
|
in** Kate finds the plugins. To use them in the *current* session without
|
||||||
|
logging out, run the export the installer prints, e.g.:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
export QT_PLUGIN_PATH="$HOME/.local/lib/x86_64-linux-gnu/qt6/plugins:$QT_PLUGIN_PATH"
|
||||||
|
```
|
||||||
|
|
||||||
|
(For a non-Plasma session, put that same line in your shell profile. For a
|
||||||
|
system-prefix install this step is unnecessary; the installer prints the ready
|
||||||
|
snippet under the build dir if you still want it.)
|
||||||
|
|
||||||
Then in Kate: Settings → Configure Kate → Plugins → enable each **`[deft:…]`**
|
Then in Kate: Settings → Configure Kate → Plugins → enable each **`[deft:…]`**
|
||||||
plugin you installed. See [The plugins](#the-plugins) below for what each one
|
plugin you installed. See [The plugins](#the-plugins) below for what each one
|
||||||
does and how to drive it.
|
does and how to drive it.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue