File: FindVorbis.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 (127 lines) | stat: -rw-r--r-- 3,955 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#[=======================================================================[.rst:
FindVorbis
-------

Finds the Vorbis library.

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

This module provides the following imported targets, if found:

``Vorbis::vorbisc``
  The Vorbis core library
``Vorbis::vorbisenc``
  The Vorbis encoder library
``Vorbis::vorbisfile``
  The Vorbis file library

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

This will define the following variables:

``Vorbis_FOUND``
  True if all vorbis libraries were found.
``Vorbis_Vorbis_FOUND``
  True if the base vorbis library was found.
``Vorbis_Enc_FOUND``
  True if the encoder library was found.
``Vorbis_File_FOUND``
  True if the file library was found.

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

# Use pkg-config if available
find_package(PkgConfig QUIET)
pkg_check_modules(PC_VORBIS QUIET vorbis)
pkg_check_modules(PC_VORBISENC QUIET vorbisenc)
pkg_check_modules(PC_VORBISFILE QUIET vorbisfile)

# Find the headers and libraries
find_path(
  Vorbis_INCLUDE_DIR
  NAMES "vorbis/codec.h"
  HINTS "${PC_VORBIS_INCLUDEDIR}")

find_library(
  Vorbis_LIBRARY
  NAMES "vorbis"
  HINTS "${PC_VORBIS_LIBDIR}")

find_library(
  Vorbis_Enc_LIBRARY
  NAMES "vorbisenc"
  HINTS "${PC_VORBISENC_LIBDIR}")

find_library(
  Vorbis_File_LIBRARY
  NAMES "vorbisfile"
  HINTS "${PC_VORBISFILE_LIBDIR}")

# Handle transitive dependencies
if(PC_VORBIS_FOUND)
  get_target_properties_from_pkg_config("${Vorbis_LIBRARY}" "PC_VORBIS"
                                        "_vorbis")
else()
  if(NOT TARGET Ogg::ogg)
    find_package(Ogg QUIET)
  endif()
  set(_vorbis_link_libraries "Ogg::ogg" ${MATH_LIBRARY})
endif()

# Extract additional flags if pkg-config is available
if(PC_VORBISENC_FOUND)
  get_target_properties_from_pkg_config("${Vorbis_Enc_LIBRARY}" "PC_VORBISENC"
                                        "_vorbis_enc")
endif()

if(PC_VORBISFILE_FOUND)
  get_target_properties_from_pkg_config("${Vorbis_File_LIBRARY}"
                                        "PC_VORBISFILE" "_vorbis_file")
endif()

# Forward the result to CMake
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
  Vorbis REQUIRED_VARS "Vorbis_LIBRARY" "Vorbis_Enc_LIBRARY"
                       "Vorbis_File_LIBRARY" "Vorbis_INCLUDE_DIR")

# Create the targets
if(Vorbis_FOUND AND NOT TARGET Vorbis::vorbis)
  add_library(Vorbis::vorbis UNKNOWN IMPORTED)
  set_target_properties(
    Vorbis::vorbis
    PROPERTIES IMPORTED_LOCATION "${Vorbis_LIBRARY}"
               INTERFACE_COMPILE_OPTIONS "${_vorbis_compile_options}"
               INTERFACE_INCLUDE_DIRECTORIES "${Vorbis_INCLUDE_DIR}"
               INTERFACE_LINK_LIBRARIES "${_vorbis_link_libraries}"
               INTERFACE_LINK_DIRECTORIES "${_vorbis_link_directories}")
  set(Vorbis_Vorbis_FOUND TRUE)
endif()

if(Vorbis_FOUND AND NOT TARGET Vorbis::vorbisenc)
  add_library(Vorbis::vorbisenc UNKNOWN IMPORTED)
  set_target_properties(
    Vorbis::vorbisenc
    PROPERTIES IMPORTED_LOCATION "${Vorbis_Enc_LIBRARY}"
               INTERFACE_COMPILE_OPTIONS "${_vorbis_enc_compile_options}"
               INTERFACE_INCLUDE_DIRECTORIES "${Vorbis_INCLUDE_DIR}"
               INTERFACE_LINK_LIBRARIES "Vorbis::vorbis"
               INTERFACE_LINK_DIRECTORIES "${_vorbis_enc_link_directories}")
  set(Vorbis_Enc_FOUND TRUE)
endif()

if(Vorbis_FOUND AND NOT TARGET Vorbis::vorbisfile)
  add_library(Vorbis::vorbisfile UNKNOWN IMPORTED)
  set_target_properties(
    Vorbis::vorbisfile
    PROPERTIES IMPORTED_LOCATION "${Vorbis_File_LIBRARY}"
               INTERFACE_COMPILE_OPTIONS "${_vorbis_file_compile_options}"
               INTERFACE_INCLUDE_DIRECTORIES "${Vorbis_INCLUDE_DIR}"
               INTERFACE_LINK_LIBRARIES "Vorbis::vorbis"
               INTERFACE_LINK_DIRECTORIES "${_vorbis_file_link_directories}")
  set(Vorbis_File_FOUND TRUE)
endif()

mark_as_advanced(Vorbis_LIBRARY Vorbis_Enc_LIBRARY Vorbis_File_LIBRARY)