diff options
| author | Jonathan Marten <jjm@keelhaul.me.uk> | 2017-11-06 12:48:41 +0000 | 
|---|---|---|
| committer | Jonathan Marten <jjm@keelhaul.me.uk> | 2017-11-06 12:48:41 +0000 | 
| commit | ee5b036c1df4776a258c0d8067fd2eaf18875829 (patch) | |
| tree | 86df6c23ae0ab642b83d52e4949e8f3b0d0d2031 | |
| parent | f7707bb546bc2a115b821dd7bcaa1e234e70acbc (diff) | |
| download | extra-cmake-modules-ee5b036c1df4776a258c0d8067fd2eaf18875829.tar.gz extra-cmake-modules-ee5b036c1df4776a258c0d8067fd2eaf18875829.tar.bz2 | |
Add FindGLIB2.cmake and FindPulseAudio.cmake
Will initially be used by KMix.
Differential Revision: https://phabricator.kde.org/D7823
| -rw-r--r-- | docs/find-module/FindGLIB2.rst | 1 | ||||
| -rw-r--r-- | docs/find-module/FindPulseAudio.rst | 1 | ||||
| -rw-r--r-- | find-modules/FindGLIB2.cmake | 98 | ||||
| -rw-r--r-- | find-modules/FindPulseAudio.cmake | 126 | 
4 files changed, 226 insertions, 0 deletions
| diff --git a/docs/find-module/FindGLIB2.rst b/docs/find-module/FindGLIB2.rst new file mode 100644 index 00000000..0ed6a2dd --- /dev/null +++ b/docs/find-module/FindGLIB2.rst @@ -0,0 +1 @@ +.. ecm-module:: ../../find-modules/FindGLIB2.cmake diff --git a/docs/find-module/FindPulseAudio.rst b/docs/find-module/FindPulseAudio.rst new file mode 100644 index 00000000..4bff4553 --- /dev/null +++ b/docs/find-module/FindPulseAudio.rst @@ -0,0 +1 @@ +.. ecm-module:: ../../find-modules/FindPulseAudio.cmake diff --git a/find-modules/FindGLIB2.cmake b/find-modules/FindGLIB2.cmake new file mode 100644 index 00000000..23a696e3 --- /dev/null +++ b/find-modules/FindGLIB2.cmake @@ -0,0 +1,98 @@ +#.rst: +# FindGLIB2 +# --------- +# +# Try to locate the GLib2 library. +# If found, this will define the following variables: +# +# ``GLIB2_FOUND`` +#     True if the GLib2 library is available +# ``GLIB2_INCLUDE_DIRS`` +#     The GLib2 include directories +# ``GLIB2_LIBRARIES`` +#     The GLib2 libraries for linking +# ``GLIB2_INCLUDE_DIR`` +#     Deprecated, use ``GLIB2_INCLUDE_DIRS`` +# ``GLIB2_LIBRARY`` +#     Deprecated, use ``GLIB2_LIBRARIES`` +# +# If ``GLIB2_FOUND`` is TRUE, it will also define the following +# imported target: +# +# ``GLIB2::GLIB2`` +#     The GLIB2 library +# +# Since 5.41.0. + +#============================================================================= +# Copyright (c) 2008 Laurent Montel, <montel@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 copyright +#    notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the copyright +#    notice, this list of conditions and the following disclaimer in the +#    documentation and/or other materials provided with the distribution. +# 3. The name of the author may not be used to endorse or promote products +#    derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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(PkgConfig) +pkg_check_modules(PC_GLIB2 QUIET glib-2.0) + +find_path(GLIB2_INCLUDE_DIRS +          NAMES glib.h +          HINTS ${PC_GLIB2_INCLUDEDIR} +          PATH_SUFFIXES glib-2.0) + +find_library(GLIB2_LIBRARIES +             NAMES glib-2.0 +             HINTS ${PC_GLIB2_LIBDIR} +) + +# search the glibconfig.h include dir under the same root where the library is found +get_filename_component(glib2LibDir "${GLIB2_LIBRARIES}" PATH) + +find_path(GLIB2_INTERNAL_INCLUDE_DIR glibconfig.h +          PATH_SUFFIXES glib-2.0/include +          HINTS ${PC_GLIB2_INCLUDEDIR} "${glib2LibDir}" ${CMAKE_SYSTEM_LIBRARY_PATH}) + +# not sure if this include dir is optional or required +# for now it is optional +if(GLIB2_INTERNAL_INCLUDE_DIR) +  list(APPEND GLIB2_INCLUDE_DIRS "${GLIB2_INTERNAL_INCLUDE_DIR}") +endif() + +# Deprecated synonyms +set(GLIB2_INCLUDE_DIR "${GLIB2_INCLUDE_DIRS}") +set(GLIB2_LIBRARY "${GLIB2_LIBRARIES}") + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GLIB2 DEFAULT_MSG GLIB2_LIBRARIES GLIB2_INCLUDE_DIRS) + +if(GLIB2_FOUND AND NOT TARGET GLIB2::GLIB2) +  add_library(GLIB2::GLIB2 UNKNOWN IMPORTED) +  set_target_properties(GLIB2::GLIB2 PROPERTIES +                        IMPORTED_LOCATION "${GLIB2_LIBRARIES}" +			INTERFACE_INCLUDE_DIRECTORIES "${GLIB2_INCLUDE_DIRS}") +endif() + +mark_as_advanced(GLIB2_INCLUDE_DIRS GLIB2_INCLUDE_DIR +                 GLIB2_LIBRARIES GLIB2_LIBRARY) +set_package_properties(GLIB2 PROPERTIES +  URL "https://wiki.gnome.org/Projects/GLib" +  DESCRIPTION "Event loop and utility library") diff --git a/find-modules/FindPulseAudio.cmake b/find-modules/FindPulseAudio.cmake new file mode 100644 index 00000000..0858eb79 --- /dev/null +++ b/find-modules/FindPulseAudio.cmake @@ -0,0 +1,126 @@ +#.rst: +# FindPulseAudio +# -------------- +# +# Try to locate the PulseAudio library. +# If found, this will define the following variables: +# +# ``PulseAudio_FOUND`` +#      True if the system has the PulseAudio library of at least +#      the minimum version specified by either the version parameter +#      to find_package() or the variable PulseAudio_MINIMUM_VERSION +# ``PulseAudio_INCLUDE_DIRS`` +#      The PulseAudio include directory +# ``PulseAudio_LIBRARIES`` +#      The PulseAudio libraries for linking +# ``PulseAudio_MAINLOOP_LIBRARY`` +#      The libraries needed to use PulseAudio Mainloop +# ``PulseAudio_VERSION`` +#      The version of PulseAudio that was found +# ``PulseAudio_INCLUDE_DIR`` +#     Deprecated, use ``PulseAudio_INCLUDE_DIRS`` +# ``PulseAudio_LIBRARY`` +#     Deprecated, use ``PulseAudio_LIBRARIES`` +# +# If ``PulseAudio_FOUND`` is TRUE, it will also define the following +# imported target: +# +# ``PulseAudio::PulseAudio`` +#     The PulseAudio library +# +# Since 5.41.0. + +#============================================================================= +# Copyright (c) 2008, Matthias Kretz, <kretz@kde.org> +# Copyright (c) 2009, Marcus Hufgard, <Marcus.Hufgard@hufgard.de> +# +# 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 copyright +#    notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the copyright +#    notice, this list of conditions and the following disclaimer in the +#    documentation and/or other materials provided with the distribution. +# 3. The name of the author may not be used to endorse or promote products +#    derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. +#============================================================================= + +# Support PulseAudio_MINIMUM_VERSION for compatibility: +if(NOT PulseAudio_FIND_VERSION) +  set(PulseAudio_FIND_VERSION "${PulseAudio_MINIMUM_VERSION}") +endif() + +# the minimum version of PulseAudio we require +if(NOT PulseAudio_FIND_VERSION) +  set(PulseAudio_FIND_VERSION "0.9.9") +endif() + +find_package(PkgConfig) +pkg_check_modules(PC_PulseAudio QUIET libpulse>=${PulseAudio_FIND_VERSION}) +pkg_check_modules(PC_PulseAudio_MAINLOOP QUIET libpulse-mainloop-glib) + +find_path(PulseAudio_INCLUDE_DIRS pulse/pulseaudio.h +   HINTS +   ${PC_PulseAudio_INCLUDEDIR} +   ${PC_PulseAudio_INCLUDE_DIRS} +   ) + +find_library(PulseAudio_LIBRARIES NAMES pulse libpulse +   HINTS +   ${PC_PulseAudio_LIBDIR} +   ${PC_PulseAudio_LIBRARY_DIRS} +   ) + +find_library(PulseAudio_MAINLOOP_LIBRARY NAMES pulse-mainloop pulse-mainloop-glib libpulse-mainloop-glib +   HINTS +   ${PC_PulseAudio_LIBDIR} +   ${PC_PulseAudio_LIBRARY_DIRS} +   ) + +# Store the version number in the cache, so we don't have to search every time again: +if (PulseAudio_INCLUDE_DIRS AND NOT PulseAudio_VERSION) + +   # get PulseAudio's version from its version.h +   file(STRINGS "${PulseAudio_INCLUDE_DIRS}/pulse/version.h" pulse_version_h +        REGEX ".*pa_get_headers_version\\(\\).*") +   string(REGEX REPLACE ".*pa_get_headers_version\\(\\)\ \\(\"([0-9]+\\.[0-9]+\\.[0-9]+)[^\"]*\"\\).*" "\\1" +                         _PulseAudio_VERSION "${pulse_version_h}") + +   set(PulseAudio_VERSION "${_PulseAudio_VERSION}" CACHE STRING "Version number of PulseAudio" FORCE) +endif() + +# Deprecated synonyms +set(PulseAudio_INCLUDE_DIR "${PulseAudio_INCLUDE_DIRS}") +set(PulseAudio_LIBRARY "${PulseAudio_LIBRARIES}") + +# Use the new extended syntax of find_package_handle_standard_args(), which also handles version checking: +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(PulseAudio REQUIRED_VARS PulseAudio_LIBRARIES PulseAudio_INCLUDE_DIRS +                                             VERSION_VAR PulseAudio_VERSION) + +if(PulseAudio_FOUND AND NOT TARGET PulseAudio::PulseAudio) +  add_library(PulseAudio::PulseAudio UNKNOWN IMPORTED) +  set_target_properties(PulseAudio::PulseAudio PROPERTIES +                        IMPORTED_LOCATION "${PulseAudio_LIBRARIES}" +			INTERFACE_INCLUDE_DIRECTORIES "${PulseAudio_INCLUDE_DIRS}") +endif() + +mark_as_advanced(PulseAudio_INCLUDE_DIRS PulseAudio_INCLUDE_DIR +                 PulseAudio_LIBRARIES PulseAudio_LIBRARY +		 PulseAudio_MAINLOOP_LIBRARY) +set_package_properties(PulseAudio PROPERTIES +  URL "https://www.freedesktop.org/wiki/Software/PulseAudio" +  DESCRIPTION "Sound server, for sound stream routing and mixing") | 
