Commit 9cab61ad authored by Harald Sitter's avatar Harald Sitter 🚔

find volume feedback's runtime requirements

Summary:
I'm in a good mood so there's even finders!

- FindCanberra now also sets the version (this is necessary to hint
  directories for the pulse backend lookup)
- new FindCanberraPulse attempts to find the canberra-pulse backend using
  manually constructed hinting (unfortunately canberra's pc doesn't
  define the dir so we'll basically have to guess)
- new FindSoundThemeFreedesktop which locates the freedesktop sound theme
  we actually require for the notification sound (since we have no plasma
  sound theme :()

The new finders are put to use to locate and indicate RUNTIME dependencies.
As with all runtime deps, if the finders should proof unreliable
CMAKE_DISABLE_FIND_PACKAGE_* can be used to easily silence the warnings.
They may of course also be safely ignored.

Getting canberra and the sound-theme dependency right has proven a
challenge to distributions. The problem goes back even to when kde-runtime
was still a thing and used canberra, and AFAIK wasn't even resolved by
all distributions by the time plasma 5 came around and kde-runtime killed
off. So, clearly we need to help things along a bit by properly codifying
and communicating the requirements here.

The volume feedback is effectively disabled when the pulse backend cannot
be loaded, and the actual feedback sound is by default coming from the
default xdg theme which also must be available for the feedback to work.

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D18807
parent 89992d14
......@@ -45,6 +45,21 @@ find_package(PulseAudio 5.0.0 REQUIRED)
find_package(Canberra REQUIRED)
find_package(GLIB2 REQUIRED)
find_package(CanberraPulse)
set_package_properties(CanberraPulse PROPERTIES
DESCRIPTION "Pulseaudio backend for libcanberra"
PURPOSE "Required for volume feedback sounds"
TYPE RUNTIME
)
find_package(SoundThemeFreedesktop)
set_package_properties(SoundThemeFreedesktop PROPERTIES
DESCRIPTION "The standard freedesktop sound theme"
PURPOSE "Required for volume feedback sounds"
URL "https://www.freedesktop.org/wiki/Specifications/sound-theme-spec/"
TYPE RUNTIME
)
find_package(KF5Kirigami2 ${KF5_MIN_VERSION} CONFIG)
set_package_properties(KF5Kirigami2 PROPERTIES
DESCRIPTION "A QtQuick based components set"
......
......@@ -4,8 +4,10 @@
# CANBERRA_FOUND - true if libcanberra was found
# CANBERRA_LIBRARIES - libcanberra libraries to link against
# CANBERRA_INCLUDE_DIRS - include path for libcanberra
# CANBERRA_VERSION - version of libcanberra
#
# Copyright (c) 2012 Raphael Kubo da Costa <rakuco@FreeBSD.org>
# Copyright (c) 2019 Harald Sitter <sitter@kde.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
......@@ -44,7 +46,12 @@ find_path(CANBERRA_INCLUDE_DIRS
HINTS ${PC_CANBERRA_INCLUDE_DIRS} ${PC_CANBERRA_INCLUDEDIR}
)
set(CANBERRA_VERSION ${PC_CANBERRA_VERSION})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Canberra REQUIRED_VARS CANBERRA_LIBRARIES CANBERRA_INCLUDE_DIRS)
find_package_handle_standard_args(Canberra
REQUIRED_VARS CANBERRA_LIBRARIES CANBERRA_INCLUDE_DIRS
VERSION_VAR CANBERRA_VERSION
)
mark_as_advanced(CANBERRA_LIBRARIES CANBERRA_INCLUDE_DIRS)
mark_as_advanced(CANBERRA_LIBRARIES CANBERRA_INCLUDE_DIRS CANBERRA_VERSION)
# - Find libcanberra's pulseaudio backend.
# This module defines the following variables:
#
# CanberraPulse_FOUND - true if the backend was found
#
# Copyright (c) 2019 Harald Sitter <sitter@kde.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the University nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
find_package(Canberra)
find_library(CanberraPulse_LIBRARY canberra-pulse
PATH_SUFFIXES libcanberra libcanberra-${CANBERRA_VERSION}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CanberraPulse
FOUND_VAR CanberraPulse_FOUND
REQUIRED_VARS CanberraPulse_LIBRARY
)
mark_as_advanced(CanberraPulse_LIBRARY)
# NB: CanberraPulse_LIBRARY is intentionally not documented as it serves no
# public purpose (it's a plugin, not a library).
# - Find sound-theme-freedesktop via XDG_DATA_DIRS
# This module defines the following variables:
#
# SoundThemeFreeDesktop_FOUND - true if the sound theme is found
# SoundThemeFreeDesktop_PATH - path to the index.theme file
#
# Copyright (c) 2019 Harald Sitter <sitter@kde.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the University nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
find_file(SoundThemeFreeDesktop_PATH "sounds/freedesktop/index.theme"
PATHS ENV XDG_DATA_DIRS /usr/local/share/ /usr/share/
NO_DEFAULT_PATH
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SoundThemeFreeDesktop
FOUND_VAR SoundThemeFreeDesktop_FOUND
REQUIRED_VARS SoundThemeFreeDesktop_PATH
)
mark_as_advanced(SoundThemeFreeDesktop_PATH)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment