diff --git a/meson.build b/meson.build index ca8036ce7..876ee0579 100644 --- a/meson.build +++ b/meson.build @@ -77,7 +77,8 @@ vulkan = dependency('vulkan', required: true) zlib = dependency('zlib', required: false) survive = dependency('survive', required: false) dbus = dependency('dbus-1', required: get_option('dbus')) -systemd = dependency('libsystemd', required: get_option('systemd')) +systemd = dependency('systemd', required: get_option('systemd')) +systemd_dep = dependency('libsystemd', required: get_option('systemd')) libbsd = dependency('libbsd', required: get_option('libbsd')) gst = dependency('gstreamer-1.0', required: false) gst_app = dependency('gstreamer-app-1.0', required: false) diff --git a/meson_options.txt b/meson_options.txt index 88c4ddba9..4d84d2f88 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -163,3 +163,8 @@ option('color_log', value: true, description: 'Log in color' ) + +option('systemd-user-unit-dir', + type: 'string', + description: 'Directory for user systemd units (defaults to /usr/lib/systemd/user)' +) diff --git a/src/xrt/include/xrt/meson.build b/src/xrt/include/xrt/meson.build index f524250d6..199633bea 100644 --- a/src/xrt/include/xrt/meson.build +++ b/src/xrt/include/xrt/meson.build @@ -76,7 +76,7 @@ if dbus.found() and not get_option('dbus').disabled() have_conf.set('XRT_HAVE_DBUS', true) endif -if systemd.found() and not get_option('systemd').disabled() +if systemd_dep.found() and not get_option('systemd').disabled() have_conf.set('XRT_HAVE_SYSTEMD', true) endif diff --git a/src/xrt/targets/service/meson.build b/src/xrt/targets/service/meson.build index b66865531..7fce71ce7 100644 --- a/src/xrt/targets/service/meson.build +++ b/src/xrt/targets/service/meson.build @@ -2,8 +2,8 @@ # SPDX-License-Identifier: BSL-1.0 service_deps = [pthreads, libjpeg] -if systemd.found() and not get_option('systemd').disabled() - service_deps += systemd +if systemd_dep.found() and not get_option('systemd').disabled() + service_deps += systemd_dep endif hack_deps = [] @@ -52,7 +52,11 @@ service = executable( ) service_install_path = join_paths(get_option('prefix'), 'bin', 'monado-service') -systemd_dir = join_paths(get_option('prefix'), get_option('libdir'), 'systemd', 'user') +systemd_user_services_dir = systemd.get_pkgconfig_variable('systemduserunitdir', define_variable : [ 'prefix', get_option('prefix')]) +if get_option('systemd-user-unit-dir') != '' + systemd_user_services_dir = get_option('systemd-user-unit-dir') +endif + service_conf_data = configuration_data() service_conf_data.set('UNIT_NAME', 'monado') @@ -64,7 +68,7 @@ configure_file( input: 'monado.in.service', output: 'monado.service', configuration: service_conf_data, - install_dir: systemd_dir + install_dir: systemd_user_services_dir ) socket_conf_data = configuration_data() @@ -74,5 +78,5 @@ configure_file( input: 'monado.in.socket', output: 'monado.socket', configuration: socket_conf_data, - install_dir: systemd_dir + install_dir: systemd_user_services_dir )