Debian Codegraph @

prboom2/cmake/FindOgg.cmake

raw
1 #[=======================================================================[.rst:
2 FindOgg
3 -------
4
5 Finds the Ogg library.
6
7 Imported Targets
8 ^^^^^^^^^^^^^^^^
9
10 This module provides the following imported targets, if found:
11
12 ``Ogg::ogg``
13 The Ogg library
14
15 Result Variables
16 ^^^^^^^^^^^^^^^^
17
18 This will define the following variables:
19
20 ``Ogg_FOUND``
21 True if the system has the Ogg library.
22 ``Ogg_INCLUDE_DIRS``
23 Include directories needed to use Ogg.
24 ``Ogg_LIBRARIES``
25 Libraries needed to link to Ogg.
26
27 The following variables are also set for compatibility with upstream:
28 ``OGG_INCLUDE_DIR``
29 ``OGG_INCLUDE_DIRS``
30 ``OGG_LIBRARY``
31 ``OGG_LIBRARIES``
32
33 Cache Variables
34 ^^^^^^^^^^^^^^^
35
36 The following cache variables may also be set:
37
38 ``Ogg_INCLUDE_DIR``
39 The directory containing ``ogg/ogg.h``.
40 ``Ogg_DLL``
41 The path to the Ogg Windows runtime.
42 ``Ogg_LIBRARY``
43 The path to the Ogg library.
44
45 #]=======================================================================]
46
47 find_package(PkgConfig QUIET)
48 pkg_check_modules(PC_ogg IMPORTED_TARGET ogg)
49
50 if(PC_ogg_FOUND)
51 if(NOT TARGET Ogg::ogg)
52 add_library(Ogg::ogg ALIAS PkgConfig::PC_ogg)
53 endif()
54 set(Ogg_FOUND TRUE)
55 set(Ogg_VERSION ${PC_ogg_VERSION})
56 return()
57 endif()
58
59 find_path(
60 Ogg_INCLUDE_DIR
61 NAMES ogg/ogg.h
62 )
63
64 find_file(
65 Ogg_DLL
66 NAMES ogg.dll libogg.dll libogg-0.dll
67 PATH_SUFFIXES bin
68 )
69
70 find_library(
71 Ogg_LIBRARY
72 NAMES ogg
73 )
74
75 if(Ogg_DLL OR Ogg_LIBRARY MATCHES ".so|.dylib")
76 set(_ogg_library_type SHARED)
77 else()
78 set(_ogg_library_type STATIC)
79 endif()
80
81 include(FindPackageHandleStandardArgs)
82 find_package_handle_standard_args(
83 Ogg
84 REQUIRED_VARS "Ogg_LIBRARY" "Ogg_INCLUDE_DIR"
85 )
86
87 if(Ogg_FOUND)
88 if(NOT TARGET Ogg::ogg)
89 add_library(Ogg::ogg ${_ogg_library_type} IMPORTED)
90 set_target_properties(
91 Ogg::ogg
92 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${Ogg_INCLUDE_DIR}"
93 )
94 endif()
95
96 if(Ogg_DLL)
97 set_target_properties(
98 Ogg::ogg
99 PROPERTIES IMPORTED_LOCATION "${Ogg_DLL}"
100 IMPORTED_IMPLIB "${Ogg_LIBRARY}"
101 )
102 else()
103 set_target_properties(
104 Ogg::ogg
105 PROPERTIES IMPORTED_LOCATION "${Ogg_LIBRARY}"
106 )
107 endif()
108
109 set(Ogg_INCLUDE_DIRS "${Ogg_INCLUDE_DIR}")
110 set(OGG_INCLUDE_DIR "${Ogg_INCLUDE_DIR}")
111 set(OGG_INCLUDE_DIRS "${Ogg_INCLUDE_DIR}")
112 set(Ogg_LIBRARIES Ogg::ogg)
113 set(OGG_LIBRARY Ogg::ogg)
114 set(OGG_LIBRARIES Ogg::ogg)
115 endif()
116
117 mark_as_advanced(
118 Ogg_INCLUDE_DIR
119 Ogg_DLL
120 Ogg_LIBRARY
121 )