1b815c7f3Sopenharmony_ci#[=======================================================================[.rst:
2b815c7f3Sopenharmony_ciFindVorbis
3b815c7f3Sopenharmony_ci----------
4b815c7f3Sopenharmony_ci
5b815c7f3Sopenharmony_ciFinds the native vorbis, vorbisenc amd vorbisfile includes and libraries.
6b815c7f3Sopenharmony_ci
7b815c7f3Sopenharmony_ciImported Targets
8b815c7f3Sopenharmony_ci^^^^^^^^^^^^^^^^
9b815c7f3Sopenharmony_ci
10b815c7f3Sopenharmony_ciThis module provides the following imported targets, if found:
11b815c7f3Sopenharmony_ci
12b815c7f3Sopenharmony_ci``Vorbis::vorbis``
13b815c7f3Sopenharmony_ci  The Vorbis library
14b815c7f3Sopenharmony_ci``Vorbis::vorbisenc``
15b815c7f3Sopenharmony_ci  The VorbisEnc library
16b815c7f3Sopenharmony_ci``Vorbis::vorbisfile``
17b815c7f3Sopenharmony_ci  The VorbisFile library
18b815c7f3Sopenharmony_ci
19b815c7f3Sopenharmony_ciResult Variables
20b815c7f3Sopenharmony_ci^^^^^^^^^^^^^^^^
21b815c7f3Sopenharmony_ci
22b815c7f3Sopenharmony_ciThis will define the following variables:
23b815c7f3Sopenharmony_ci
24b815c7f3Sopenharmony_ci``Vorbis_Vorbis_INCLUDE_DIRS``
25b815c7f3Sopenharmony_ci  List of include directories when using vorbis.
26b815c7f3Sopenharmony_ci``Vorbis_Enc_INCLUDE_DIRS``
27b815c7f3Sopenharmony_ci  List of include directories when using vorbisenc.
28b815c7f3Sopenharmony_ci``Vorbis_File_INCLUDE_DIRS``
29b815c7f3Sopenharmony_ci  List of include directories when using vorbisfile.
30b815c7f3Sopenharmony_ci``Vorbis_Vorbis_LIBRARIES``
31b815c7f3Sopenharmony_ci  List of libraries when using vorbis.
32b815c7f3Sopenharmony_ci``Vorbis_Enc_LIBRARIES``
33b815c7f3Sopenharmony_ci  List of libraries when using vorbisenc.
34b815c7f3Sopenharmony_ci``Vorbis_File_LIBRARIES``
35b815c7f3Sopenharmony_ci  List of libraries when using vorbisfile.
36b815c7f3Sopenharmony_ci``Vorbis_FOUND``
37b815c7f3Sopenharmony_ci  True if vorbis and requested components found.
38b815c7f3Sopenharmony_ci``Vorbis_Vorbis_FOUND``
39b815c7f3Sopenharmony_ci  True if vorbis found.
40b815c7f3Sopenharmony_ci``Vorbis_Enc_FOUND``
41b815c7f3Sopenharmony_ci  True if vorbisenc found.
42b815c7f3Sopenharmony_ci``Vorbis_Enc_FOUND``
43b815c7f3Sopenharmony_ci  True if vorbisfile found.
44b815c7f3Sopenharmony_ci
45b815c7f3Sopenharmony_ciCache variables
46b815c7f3Sopenharmony_ci^^^^^^^^^^^^^^^
47b815c7f3Sopenharmony_ci
48b815c7f3Sopenharmony_ciThe following cache variables may also be set:
49b815c7f3Sopenharmony_ci
50b815c7f3Sopenharmony_ci``Vorbis_Vorbis_INCLUDE_DIR``
51b815c7f3Sopenharmony_ci  The directory containing ``vorbis/vorbis.h``.
52b815c7f3Sopenharmony_ci``Vorbis_Enc_INCLUDE_DIR``
53b815c7f3Sopenharmony_ci  The directory containing ``vorbis/vorbisenc.h``.
54b815c7f3Sopenharmony_ci``Vorbis_File_INCLUDE_DIR``
55b815c7f3Sopenharmony_ci  The directory containing ``vorbis/vorbisenc.h``.
56b815c7f3Sopenharmony_ci``Vorbis_Vorbis_LIBRARY``
57b815c7f3Sopenharmony_ci  The path to the vorbis library.
58b815c7f3Sopenharmony_ci``Vorbis_Enc_LIBRARY``
59b815c7f3Sopenharmony_ci  The path to the vorbisenc library.
60b815c7f3Sopenharmony_ci``Vorbis_File_LIBRARY``
61b815c7f3Sopenharmony_ci  The path to the vorbisfile library.
62b815c7f3Sopenharmony_ci
63b815c7f3Sopenharmony_ciHints
64b815c7f3Sopenharmony_ci^^^^^
65b815c7f3Sopenharmony_ci
66b815c7f3Sopenharmony_ciA user may set ``Vorbis_ROOT`` to a vorbis installation root to tell this module where to look.
67b815c7f3Sopenharmony_ci
68b815c7f3Sopenharmony_ci#]=======================================================================]
69b815c7f3Sopenharmony_ci
70b815c7f3Sopenharmony_ciif (Vorbis_Vorbis_INCLUDE_DIR)
71b815c7f3Sopenharmony_ci	# Already in cache, be silent
72b815c7f3Sopenharmony_ci	set (Vorbis_FIND_QUIETLY TRUE)
73b815c7f3Sopenharmony_ciendif ()
74b815c7f3Sopenharmony_ci
75b815c7f3Sopenharmony_ciset (Vorbis_Vorbis_FIND_QUIETLY TRUE)
76b815c7f3Sopenharmony_ciset (Vorbis_Enc_FIND_QUIETLY TRUE)
77b815c7f3Sopenharmony_ciset (Vorbis_File_FIND_QUIETLY TRUE)
78b815c7f3Sopenharmony_ci
79b815c7f3Sopenharmony_cifind_package (Ogg QUIET)
80b815c7f3Sopenharmony_ci
81b815c7f3Sopenharmony_cifind_package (PkgConfig QUIET)
82b815c7f3Sopenharmony_cipkg_check_modules (PC_Vorbis_Vorbis QUIET vorbis)
83b815c7f3Sopenharmony_cipkg_check_modules (PC_Vorbis_Enc QUIET vorbisenc)
84b815c7f3Sopenharmony_cipkg_check_modules (PC_Vorbis_File QUIET vorbisfile)
85b815c7f3Sopenharmony_ci
86b815c7f3Sopenharmony_ciset (Vorbis_VERSION ${PC_Vorbis_Vorbis_VERSION})
87b815c7f3Sopenharmony_ci
88b815c7f3Sopenharmony_cifind_path (Vorbis_Vorbis_INCLUDE_DIR vorbis/codec.h
89b815c7f3Sopenharmony_ci	HINTS
90b815c7f3Sopenharmony_ci		${PC_Vorbis_Vorbis_INCLUDEDIR}
91b815c7f3Sopenharmony_ci		${PC_Vorbis_Vorbis_INCLUDE_DIRS}
92b815c7f3Sopenharmony_ci		${Vorbis_ROOT}
93b815c7f3Sopenharmony_ci	)
94b815c7f3Sopenharmony_ci
95b815c7f3Sopenharmony_cifind_path (Vorbis_Enc_INCLUDE_DIR vorbis/vorbisenc.h
96b815c7f3Sopenharmony_ci	HINTS
97b815c7f3Sopenharmony_ci		${PC_Vorbis_Enc_INCLUDEDIR}
98b815c7f3Sopenharmony_ci		${PC_Vorbis_Enc_INCLUDE_DIRS}
99b815c7f3Sopenharmony_ci		${Vorbis_ROOT}
100b815c7f3Sopenharmony_ci	)
101b815c7f3Sopenharmony_ci
102b815c7f3Sopenharmony_cifind_path (Vorbis_File_INCLUDE_DIR vorbis/vorbisfile.h
103b815c7f3Sopenharmony_ci	HINTS
104b815c7f3Sopenharmony_ci		${PC_Vorbis_File_INCLUDEDIR}
105b815c7f3Sopenharmony_ci		${PC_Vorbis_File_INCLUDE_DIRS}
106b815c7f3Sopenharmony_ci		${Vorbis_ROOT}
107b815c7f3Sopenharmony_ci	)
108b815c7f3Sopenharmony_ci
109b815c7f3Sopenharmony_cifind_library (Vorbis_Vorbis_LIBRARY
110b815c7f3Sopenharmony_ci	NAMES
111b815c7f3Sopenharmony_ci		vorbis
112b815c7f3Sopenharmony_ci		vorbis_static
113b815c7f3Sopenharmony_ci		libvorbis
114b815c7f3Sopenharmony_ci		libvorbis_static
115b815c7f3Sopenharmony_ci	HINTS
116b815c7f3Sopenharmony_ci		${PC_Vorbis_Vorbis_LIBDIR}
117b815c7f3Sopenharmony_ci		${PC_Vorbis_Vorbis_LIBRARY_DIRS}
118b815c7f3Sopenharmony_ci		${Vorbis_ROOT}
119b815c7f3Sopenharmony_ci	)
120b815c7f3Sopenharmony_ci
121b815c7f3Sopenharmony_cifind_library (Vorbis_Enc_LIBRARY
122b815c7f3Sopenharmony_ci	NAMES
123b815c7f3Sopenharmony_ci		vorbisenc
124b815c7f3Sopenharmony_ci		vorbisenc_static
125b815c7f3Sopenharmony_ci		libvorbisenc
126b815c7f3Sopenharmony_ci		libvorbisenc_static
127b815c7f3Sopenharmony_ci	HINTS
128b815c7f3Sopenharmony_ci		${PC_Vorbis_Enc_LIBDIR}
129b815c7f3Sopenharmony_ci		${PC_Vorbis_Enc_LIBRARY_DIRS}
130b815c7f3Sopenharmony_ci		${Vorbis_ROOT}
131b815c7f3Sopenharmony_ci	)
132b815c7f3Sopenharmony_ci
133b815c7f3Sopenharmony_cifind_library (Vorbis_File_LIBRARY
134b815c7f3Sopenharmony_ci	NAMES
135b815c7f3Sopenharmony_ci		vorbisfile
136b815c7f3Sopenharmony_ci		vorbisfile_static
137b815c7f3Sopenharmony_ci		libvorbisfile
138b815c7f3Sopenharmony_ci		libvorbisfile_static
139b815c7f3Sopenharmony_ci	HINTS
140b815c7f3Sopenharmony_ci		${PC_Vorbis_File_LIBDIR}
141b815c7f3Sopenharmony_ci		${PC_Vorbis_File_LIBRARY_DIRS}
142b815c7f3Sopenharmony_ci		${Vorbis_ROOT}
143b815c7f3Sopenharmony_ci	)
144b815c7f3Sopenharmony_ci
145b815c7f3Sopenharmony_ciinclude (FindPackageHandleStandardArgs)
146b815c7f3Sopenharmony_ci
147b815c7f3Sopenharmony_ciif (Vorbis_Vorbis_LIBRARY AND Vorbis_Vorbis_INCLUDE_DIR AND Ogg_FOUND)
148b815c7f3Sopenharmony_ci    set (Vorbis_Vorbis_FOUND TRUE)
149b815c7f3Sopenharmony_ciendif ()
150b815c7f3Sopenharmony_ci
151b815c7f3Sopenharmony_ciif (Vorbis_Enc_LIBRARY AND Vorbis_Enc_INCLUDE_DIR AND Vorbis_Vorbis_FOUND)
152b815c7f3Sopenharmony_ci    set (Vorbis_Enc_FOUND TRUE)
153b815c7f3Sopenharmony_ciendif ()
154b815c7f3Sopenharmony_ci
155b815c7f3Sopenharmony_ciif (Vorbis_Vorbis_FOUND AND Vorbis_File_LIBRARY AND Vorbis_File_INCLUDE_DIR)
156b815c7f3Sopenharmony_ci    set (Vorbis_File_FOUND TRUE)
157b815c7f3Sopenharmony_ciendif ()
158b815c7f3Sopenharmony_ci
159b815c7f3Sopenharmony_cifind_package_handle_standard_args (Vorbis
160b815c7f3Sopenharmony_ci	REQUIRED_VARS
161b815c7f3Sopenharmony_ci		Vorbis_Vorbis_LIBRARY
162b815c7f3Sopenharmony_ci		Vorbis_Vorbis_INCLUDE_DIR
163b815c7f3Sopenharmony_ci		Ogg_FOUND
164b815c7f3Sopenharmony_ci	HANDLE_COMPONENTS
165b815c7f3Sopenharmony_ci	VERSION_VAR Vorbis_VERSION)
166b815c7f3Sopenharmony_ci
167b815c7f3Sopenharmony_ci
168b815c7f3Sopenharmony_ciif (Vorbis_Vorbis_FOUND)
169b815c7f3Sopenharmony_ci	set (Vorbis_Vorbis_INCLUDE_DIRS ${VORBIS_INCLUDE_DIR})
170b815c7f3Sopenharmony_ci	set (Vorbis_Vorbis_LIBRARIES ${VORBIS_LIBRARY} ${OGG_LIBRARIES})
171b815c7f3Sopenharmony_ci    if (NOT TARGET Vorbis::vorbis)
172b815c7f3Sopenharmony_ci		add_library (Vorbis::vorbis UNKNOWN IMPORTED)
173b815c7f3Sopenharmony_ci		set_target_properties (Vorbis::vorbis PROPERTIES
174b815c7f3Sopenharmony_ci			INTERFACE_INCLUDE_DIRECTORIES "${Vorbis_Vorbis_INCLUDE_DIR}"
175b815c7f3Sopenharmony_ci			IMPORTED_LOCATION "${Vorbis_Vorbis_LIBRARY}"
176b815c7f3Sopenharmony_ci			INTERFACE_LINK_LIBRARIES Ogg::ogg
177b815c7f3Sopenharmony_ci		)
178b815c7f3Sopenharmony_ci	endif ()
179b815c7f3Sopenharmony_ci
180b815c7f3Sopenharmony_ci	if (Vorbis_Enc_FOUND)
181b815c7f3Sopenharmony_ci		set (Vorbis_Enc_INCLUDE_DIRS ${Vorbis_Enc_INCLUDE_DIR})
182b815c7f3Sopenharmony_ci		set (Vorbis_Enc_LIBRARIES ${Vorbis_Enc_LIBRARY} ${Vorbis_Enc_LIBRARIES})
183b815c7f3Sopenharmony_ci		if (NOT TARGET Vorbis::vorbisenc)
184b815c7f3Sopenharmony_ci			add_library (Vorbis::vorbisenc UNKNOWN IMPORTED)
185b815c7f3Sopenharmony_ci			set_target_properties (Vorbis::vorbisenc PROPERTIES
186b815c7f3Sopenharmony_ci				INTERFACE_INCLUDE_DIRECTORIES "${Vorbis_Enc_INCLUDE_DIR}"
187b815c7f3Sopenharmony_ci				IMPORTED_LOCATION "${Vorbis_Enc_LIBRARY}"
188b815c7f3Sopenharmony_ci				INTERFACE_LINK_LIBRARIES Vorbis::vorbis
189b815c7f3Sopenharmony_ci			)
190b815c7f3Sopenharmony_ci		endif ()
191b815c7f3Sopenharmony_ci	endif ()
192b815c7f3Sopenharmony_ci
193b815c7f3Sopenharmony_ci	if (Vorbis_File_FOUND)
194b815c7f3Sopenharmony_ci		set (Vorbis_File_INCLUDE_DIRS ${Vorbis_File_INCLUDE_DIR})
195b815c7f3Sopenharmony_ci		set (Vorbis_File_LIBRARIES ${Vorbis_File_LIBRARY} ${Vorbis_File_LIBRARIES})
196b815c7f3Sopenharmony_ci		if (NOT TARGET Vorbis::vorbisfile)
197b815c7f3Sopenharmony_ci			add_library (Vorbis::vorbisfile UNKNOWN IMPORTED)
198b815c7f3Sopenharmony_ci			set_target_properties (Vorbis::vorbisfile PROPERTIES
199b815c7f3Sopenharmony_ci				INTERFACE_INCLUDE_DIRECTORIES "${Vorbis_File_INCLUDE_DIR}"
200b815c7f3Sopenharmony_ci				IMPORTED_LOCATION "${Vorbis_File_LIBRARY}"
201b815c7f3Sopenharmony_ci				INTERFACE_LINK_LIBRARIES Vorbis::vorbis
202b815c7f3Sopenharmony_ci			)
203b815c7f3Sopenharmony_ci		endif ()
204b815c7f3Sopenharmony_ci	endif ()
205b815c7f3Sopenharmony_ci
206b815c7f3Sopenharmony_ciendif ()
207b815c7f3Sopenharmony_ci
208b815c7f3Sopenharmony_cimark_as_advanced (Vorbis_Vorbis_INCLUDE_DIR Vorbis_Vorbis_LIBRARY)
209b815c7f3Sopenharmony_cimark_as_advanced (Vorbis_Enc_INCLUDE_DIR Vorbis_Enc_LIBRARY)
210b815c7f3Sopenharmony_cimark_as_advanced (Vorbis_File_INCLUDE_DIR Vorbis_File_LIBRARY)
211