summaryrefslogtreecommitdiffstats
path: root/cmake/modules/FindOpus.cmake
blob: 18d4a447ec3342ebf15dec3d4d4a7c8a502ff0fb (plain)
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
# This file is part of Mixxx, Digital DJ'ing software.
# Copyright (C) 2001-2020 Mixxx Development Team
# Distributed under the GNU General Public Licence (GPL) version 2 or any later
# later version. See the LICENSE file for details.

#[=======================================================================[.rst:
FindOpus
--------

Finds the Opus library.

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

This will define the following variables:

``Opus_FOUND``
  True if the system has the Opus library.
``Opus_INCLUDE_DIRS``
  Include directories needed to use Opus.
``Opus_LIBRARIES``
  Libraries needed to link to Opus.
``Opus_DEFINITIONS``
  Compile definitions needed to use Opus.

Cache Variables
^^^^^^^^^^^^^^^

The following cache variables may also be set:

``Opus_INCLUDE_DIR``
  The directory containing ``opus.h``.
``Opus_LIBRARY``
  The path to the Opus library.
``OpusFile_INCLUDE_DIR``
  The directory containing ``opusfile.h``.
``OpusFile_LIBRARY``
  The path to the Opus library.

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

find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
  pkg_check_modules(PC_Opus QUIET opus)
  pkg_check_modules(PC_OpusFile QUIET opusfile)
endif()

find_path(Opus_INCLUDE_DIR
  NAMES opus/opus.h
  PATHS ${PC_Opus_INCLUDE_DIRS}
  DOC "Opus include directory")
mark_as_advanced(Opus_INCLUDE_DIR)

find_library(Opus_LIBRARY
  NAMES opus
  PATHS ${PC_Opus_LIBRARY_DIRS}
  DOC "Opus library"
)
mark_as_advanced(Opus_LIBRARY)

find_path(OpusFile_INCLUDE_DIR
  NAMES opusfile.h
  PATH_SUFFIXES opus
  PATHS ${PC_OpusFile_INCLUDE_DIRS}
  DOC "Opusfile include directory")
mark_as_advanced(OpusFile_INCLUDE_DIR)

find_library(OpusFile_LIBRARY
  NAMES opusfile
  PATHS ${PC_OpusFile_LIBRARY_DIRS}
  DOC "Opusfile library"
)
mark_as_advanced(OpusFile_LIBRARY)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
  Opus
  DEFAULT_MSG
  Opus_LIBRARY
  Opus_INCLUDE_DIR
  OpusFile_LIBRARY
  OpusFile_INCLUDE_DIR
)

if(Opus_FOUND)
  set(Opus_LIBRARIES ${Opus_LIBRARY} ${OpusFile_LIBRARY})
  set(Opus_INCLUDE_DIRS ${Opus_INCLUDE_DIR} ${OpusFile_INCLUDE_DIR})
  set(Opus_DEFINITIONS ${PC_Opus_CFLAGS_OTHER} ${PC_OpusFile_CFLAGS_OTHER})
endif()