File: FindOgg.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 (84 lines) | stat: -rw-r--r-- 2,188 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
#[=======================================================================[.rst:
FindOgg
-------

Finds the Ogg library.

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

This module provides the following imported targets, if found:

``Ogg::ogg``
  The Ogg library

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

This will define the following variables:

``Ogg_FOUND``
  True if the system has the Ogg library.

For compatibility with upstream, the following variables are also set:

``Ogg_INCLUDE_DIR``
``Ogg_INCLUDE_DIRS``
``Ogg_LIBRARY``
``Ogg_LIBRARIES``
``OGG_INCLUDE_DIR``
``OGG_INCLUDE_DIRS``
``OGG_LIBRARY``
``OGG_LIBRARIES``
``OGG_FOUND``

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

# Use pkg-config if available
find_package(PkgConfig QUIET)
pkg_check_modules(PC_OGG QUIET ogg)

# Find the headers and library
find_path(
  Ogg_INCLUDE_DIR
  NAMES "ogg/ogg.h"
  HINTS "${PC_OGG_INCLUDEDIR}")

find_library(
  _ogg_library
  NAMES "ogg"
  HINTS "${PC_OGG_LIBDIR}")

# Extract additional flags if pkg-config is available
if(PC_OGG_FOUND)
  get_target_properties_from_pkg_config("${_ogg_library}" "PC_OGG" "_ogg")
endif()

# Forward the result to CMake
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Ogg REQUIRED_VARS "_ogg_library"
                                                    "Ogg_INCLUDE_DIR")

# Create the target
if(Ogg_FOUND AND NOT TARGET Ogg::ogg)
  add_library(Ogg::ogg UNKNOWN IMPORTED)
  set_target_properties(
    Ogg::ogg
    PROPERTIES IMPORTED_LOCATION "${_ogg_library}"
               INTERFACE_COMPILE_OPTIONS "${_ogg_compile_options}"
               INTERFACE_INCLUDE_DIRECTORIES "${Ogg_INCLUDE_DIR}"
               INTERFACE_LINK_LIBRARIES "${_ogg_link_libraries}"
               INTERFACE_LINK_DIRECTORIES "${_ogg_link_directories}")

  # Set additional variables for compatibility with upstream config
  set(Ogg_INCLUDE_DIRS "${Ogg_INCLUDE_DIR}")
  set(Ogg_LIBRARY Ogg::ogg)
  set(Ogg_LIBRARIES Ogg::ogg)
  set(OGG_INCLUDE_DIR "${${Ogg_INCLUDE_DIR}}")
  set(OGG_INCLUDE_DIRS "${${Ogg_INCLUDE_DIR}}")
  set(OGG_LIBRARY Ogg::ogg)
  set(OGG_LIBRARIES Ogg::ogg)
  set(OGG_FOUND TRUE)
endif()

mark_as_advanced(_ogg_library)