eigenmath: 3.33-unstable-2024-11-22 -> 3.35-unstable-2024-12-11 (#364381)
[NixPkgs.git] / pkgs / kde / frameworks / extra-cmake-modules / ecm-hook.sh
blobc635816777f52c2f11e65967e3046064ea412003
1 # shellcheck shell=bash
2 # Variables we use here are set by the stdenv, no use complaining about them
3 # shellcheck disable=SC2164
5 ecmEnvHook() {
6 addToSearchPath XDG_DATA_DIRS "$1/share"
7 addToSearchPath XDG_CONFIG_DIRS "$1/etc/xdg"
9 addEnvHooks "$hostOffset" ecmEnvHook
11 ecmPostHook() {
12 # Because we need to use absolute paths here, we must set *all* the paths.
13 # Keep this in sync with https://github.com/KDE/extra-cmake-modules/blob/master/kde-modules/KDEInstallDirs6.cmake
14 if [ "$(uname)" = "Darwin" ]; then
15 appendToVar cmakeFlags "-DKDE_INSTALL_BUNDLEDIR=${!outputBin}/Applications/KDE"
18 appendToVar cmakeFlags "-DKDE_INSTALL_EXECROOTDIR=${!outputBin}"
19 appendToVar cmakeFlags "-DKDE_INSTALL_BINDIR=${!outputBin}/bin"
20 appendToVar cmakeFlags "-DKDE_INSTALL_SBINDIR=${!outputBin}/sbin"
21 appendToVar cmakeFlags "-DKDE_INSTALL_LIBDIR=${!outputLib}/lib"
22 appendToVar cmakeFlags "-DKDE_INSTALL_LIBEXECDIR=${!outputLib}/libexec"
23 appendToVar cmakeFlags "-DKDE_INSTALL_CMAKEPACKAGEDIR=${!outputDev}/lib/cmake"
25 if [ -n "${qtPluginPrefix-}" ]; then
26 appendToVar cmakeFlags "-DKDE_INSTALL_QTPLUGINDIR=${!outputBin}/$qtPluginPrefix"
27 appendToVar cmakeFlags "-DKDE_INSTALL_PLUGINDIR=${!outputBin}/$qtPluginPrefix"
30 if [ -n "${qtQmlPrefix-}" ]; then
31 appendToVar cmakeFlags "-DKDE_INSTALL_QMLDIR=${!outputBin}/$qtQmlPrefix"
34 appendToVar cmakeFlags "-DKDE_INSTALL_INCLUDEDIR=${!outputInclude}/include"
35 appendToVar cmakeFlags "-DKDE_INSTALL_LOCALSTATEDIR=/var"
36 appendToVar cmakeFlags "-DKDE_INSTALL_SHAREDSTATEDIR=/com" # ???
37 appendToVar cmakeFlags "-DKDE_INSTALL_DATAROOTDIR=${!outputBin}/share"
38 appendToVar cmakeFlags "-DKDE_INSTALL_DATADIR=${!outputBin}/share"
39 appendToVar cmakeFlags "-DKDE_INSTALL_DOCBUNDLEDIR=${!outputBin}/share/doc/HTML"
40 appendToVar cmakeFlags "-DKDE_INSTALL_KCFGDIR=${!outputBin}/share/config.kcfg"
41 appendToVar cmakeFlags "-DKDE_INSTALL_KCONFUPDATEDIR=${!outputBin}/share/kconf_update"
42 appendToVar cmakeFlags "-DKDE_INSTALL_KAPPTEMPLATESDIR=${!outputDev}/share/kdevappwizard/templates"
43 appendToVar cmakeFlags "-DKDE_INSTALL_KFILETEMPLATESDIR=${!outputDev}/share/kdevfiletemplates/templates"
44 appendToVar cmakeFlags "-DKDE_INSTALL_KXMLGUIDIR=${!outputBin}/share/kxmlgui5" # Yes, this needs to be 5 and not 6. Don't ask.
45 appendToVar cmakeFlags "-DKDE_INSTALL_KNOTIFYRCDIR=${!outputBin}/share/knotifications6"
46 appendToVar cmakeFlags "-DKDE_INSTALL_ICONDIR=${!outputBin}/share/icons"
47 appendToVar cmakeFlags "-DKDE_INSTALL_LOCALEDIR=${!outputLib}/share/locale"
48 appendToVar cmakeFlags "-DKDE_INSTALL_SOUNDDIR=${!outputBin}/share/sounds"
49 appendToVar cmakeFlags "-DKDE_INSTALL_TEMPLATEDIR=${!outputBin}/share/templates"
50 appendToVar cmakeFlags "-DKDE_INSTALL_WALLPAPERDIR=${!outputBin}/share/wallpapers"
51 appendToVar cmakeFlags "-DKDE_INSTALL_APPDIR=${!outputBin}/share/applications"
52 appendToVar cmakeFlags "-DKDE_INSTALL_DESKTOPDIR=${!outputBin}/share/desktop-directories"
53 appendToVar cmakeFlags "-DKDE_INSTALL_MIMEDIR=${!outputBin}/share/mime/packages"
54 appendToVar cmakeFlags "-DKDE_INSTALL_METAINFODIR=${!outputBin}/share/appdata"
55 appendToVar cmakeFlags "-DKDE_INSTALL_QTQCHDIR=${!outputLib}/share/doc/qch"
56 appendToVar cmakeFlags "-DKDE_INSTALL_QCHDIR=${!outputLib}/share/doc/qch"
57 appendToVar cmakeFlags "-DKDE_INSTALL_MANDIR=${!outputBin}/share/man"
58 appendToVar cmakeFlags "-DKDE_INSTALL_INFODIR=${!outputBin}/share/info"
59 appendToVar cmakeFlags "-DKDE_INSTALL_DBUSDIR=${!outputBin}/share/dbus-1"
60 appendToVar cmakeFlags "-DKDE_INSTALL_DBUSINTERFACEDIR=${!outputBin}/share/dbus-1/interfaces"
61 appendToVar cmakeFlags "-DKDE_INSTALL_DBUSSERVICEDIR=${!outputBin}/share/dbus-1/services"
62 appendToVar cmakeFlags "-DKDE_INSTALL_DBUSSYSTEMSERVICEDIR=${!outputBin}/share/dbus-1/system-services"
63 appendToVar cmakeFlags "-DKDE_INSTALL_SYSCONFDIR=${!outputBin}/etc"
64 appendToVar cmakeFlags "-DKDE_INSTALL_CONFDIR=${!outputBin}/etc/xdg"
65 appendToVar cmakeFlags "-DKDE_INSTALL_AUTOSTARTDIR=${!outputBin}/etc/xdg/autostart"
66 appendToVar cmakeFlags "-DKDE_INSTALL_LOGGINGCATEGORIESDIR=${!outputLib}/share/qlogging-categories6"
67 appendToVar cmakeFlags "-DKDE_INSTALL_SYSTEMDUNITDIR=${!outputBin}/lib/systemd"
68 appendToVar cmakeFlags "-DKDE_INSTALL_SYSTEMDUSERUNITDIR=${!outputBin}/share/systemd/user"
70 postHooks+=(ecmPostHook)
72 xdgDataSubdirs=("config.kcfg" "kconf_update" "knotifications6" "icons" "locale" "mime")
74 # ecmHostPathsSeen is an associative array of the paths that have already been
75 # seen by ecmHostPathHook.
76 declare -gA ecmHostPathsSeen
78 ecmHostPathIsNotSeen() {
79 if [[ -n "${ecmHostPathsSeen["$1"]:-}" ]]; then
80 # The path has been seen before.
81 return 1
82 else
83 # The path has not been seen before.
84 # Now it is seen, so record it.
85 ecmHostPathsSeen["$1"]=1
86 return 0
90 ecmHostPathHook() {
91 ecmHostPathIsNotSeen "$1" || return 0
93 local xdgConfigDir="$1/etc/xdg"
94 if [ -d "$xdgConfigDir" ]
95 then
96 qtWrapperArgs+=(--prefix XDG_CONFIG_DIRS : "$xdgConfigDir")
99 for xdgDataSubdir in "${xdgDataSubdirs[@]}"
101 if [ -d "$1/share/$xdgDataSubdir" ]
102 then
103 qtWrapperArgs+=(--prefix XDG_DATA_DIRS : "$1/share")
104 break
106 done
108 if [ -d "$1/share/dbus-1" ]
109 then
110 propagatedUserEnvPkgs+=" $1"
113 addEnvHooks "$hostOffset" ecmHostPathHook