File: Findmpg123.cmake

package info (click to toggle)
fluidsynth 2.4.4%2Bdfsg-1%2Bdeb13u1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,328 kB
  • sloc: ansic: 43,529; cpp: 1,434; xml: 1,020; makefile: 71; sh: 46
file content (108 lines) | stat: -rw-r--r-- 3,172 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#[=======================================================================[.rst:
Findmpg123
-------

Finds the mpg123 library.

Imported Targets
^^^^^^^^^^^^^^^^

This module provides the following imported targets, if found:

``MPG123::libmpg123``
  The mpg123 decoder library
``MPG123::libout123``
  The mpg123 output library
``MPG123::libsyn123``
  The mpg123 signal synthesis library

Result Variables
^^^^^^^^^^^^^^^^

This will define the following variables:

``mpg123_FOUND``
  True if the package was found.
``mpg123_libmpg123_FOUND``
  True if the decoder library was found.
``mpg123_libout123_FOUND``
  True if the output library was found.
``mpg123_libsyn123_FOUND``
  True if the signal synthesis library was found.

#]=======================================================================]

# Use pkg-config if available
find_package(PkgConfig QUIET)
pkg_check_modules(PC_MPG123 QUIET libmpg123)
pkg_check_modules(PC_OUT123 QUIET libout123)
pkg_check_modules(PC_SYN123 QUIET libsyn123)

# Find the headers and libraries
find_path(
  mpg123_INCLUDE_DIR
  NAMES "mpg123.h"
  HINTS "${PC_MPG123_INCLUDEDIR}")

find_library(
  mpg123_libmpg123_LIBRARY
  NAMES "mpg123"
  HINTS "${PC_MPG123_LIBDIR}")

find_library(
  mpg123_libout123_LIBRARY
  NAMES "out123"
  HINTS "${PC_OUT123_LIBDIR}")

find_library(
  mpg123_libsyn123_LIBRARY
  NAMES "syn123"
  HINTS "${PC_SYN123_LIBDIR}")

# Extract additional flags if pkg-config is available
if(PC_MPG123_FOUND)
  get_target_properties_from_pkg_config("${mpg123_libmpg123_LIBRARY}"
                                        "PC_MPG123" "_libmpg123")
endif()
if(PC_OUT123_FOUND)
  get_target_properties_from_pkg_config("${mpg123_libout123_LIBRARY}"
                                        "PC_OUT123" "_libout123")
endif()
if(PC_SYN123_FOUND)
  get_target_properties_from_pkg_config("${mpg123_libsyn123_LIBRARY}"
                                        "PC_SYN123" "_libsyn123")
endif()

# Mark which component were found
foreach(_component libmpg123 libout123 libsyn123)
  if(mpg123_${_component}_LIBRARY)
    set(mpg123_${_component}_FOUND TRUE)
  else()
    set(mpg123_${_component}_FOUND FALSE)
  endif()
endforeach()

# Forward the result to CMake
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
  mpg123
  REQUIRED_VARS "mpg123_libmpg123_LIBRARY" "mpg123_INCLUDE_DIR"
  HANDLE_COMPONENTS)

# Create the targets
foreach(_component libmpg123 libout123 libsyn123)
  if(mpg123_${_component}_FOUND AND NOT TARGET MPG123::${_component})
    add_library(MPG123::${_component} UNKNOWN IMPORTED)
    set_target_properties(
      MPG123::${_component}
      PROPERTIES IMPORTED_LOCATION "${mpg123_${_component}_LIBRARY}"
                 INTERFACE_INCLUDE_DIRECTORIES "${mpg123_INCLUDE_DIR}"
                 INTERFACE_COMPILE_OPTIONS "${_${_component}_compile_options}"
                 INTERFACE_LINK_LIBRARIES "${_${_component}_link_libraries}"
                 INTERFACE_LINK_DIRECTORIES
                 "${_${_component}_link_directories}")
  endif()
endforeach()

mark_as_advanced(mpg123_libmpg123_LIBRARY mpg123_libout123_LIBRARY
                 mpg123_libsyn123_LIBRARY mpg123_INCLUDE_DIR)