xref: /third_party/libsnd/cmake/FindOgg.cmake (revision b815c7f3)
1b815c7f3Sopenharmony_ci# - Find ogg
2b815c7f3Sopenharmony_ci# Find the native ogg includes and libraries
3b815c7f3Sopenharmony_ci#
4b815c7f3Sopenharmony_ci#  OGG_INCLUDE_DIRS - where to find ogg.h, etc.
5b815c7f3Sopenharmony_ci#  OGG_LIBRARIES    - List of libraries when using ogg.
6b815c7f3Sopenharmony_ci#  OGG_FOUND        - True if ogg found.
7b815c7f3Sopenharmony_ci
8b815c7f3Sopenharmony_ciif (OGG_INCLUDE_DIR)
9b815c7f3Sopenharmony_ci	# Already in cache, be silent
10b815c7f3Sopenharmony_ci	set(OGG_FIND_QUIETLY TRUE)
11b815c7f3Sopenharmony_ciendif ()
12b815c7f3Sopenharmony_ci
13b815c7f3Sopenharmony_cifind_package (PkgConfig QUIET)
14b815c7f3Sopenharmony_cipkg_check_modules (PC_OGG QUIET ogg>=1.3.0)
15b815c7f3Sopenharmony_ci
16b815c7f3Sopenharmony_ciset (OGG_VERSION ${PC_OGG_VERSION})
17b815c7f3Sopenharmony_ci
18b815c7f3Sopenharmony_cifind_path (OGG_INCLUDE_DIR ogg/ogg.h
19b815c7f3Sopenharmony_ci	HINTS
20b815c7f3Sopenharmony_ci		${PC_OGG_INCLUDEDIR}
21b815c7f3Sopenharmony_ci		${PC_OGG_INCLUDE_DIRS}
22b815c7f3Sopenharmony_ci		${OGG_ROOT}
23b815c7f3Sopenharmony_ci	)
24b815c7f3Sopenharmony_ci# MSVC built ogg may be named ogg_static.
25b815c7f3Sopenharmony_ci# The provided project files name the library with the lib prefix.
26b815c7f3Sopenharmony_cifind_library (OGG_LIBRARY
27b815c7f3Sopenharmony_ci	NAMES
28b815c7f3Sopenharmony_ci		ogg
29b815c7f3Sopenharmony_ci		ogg_static
30b815c7f3Sopenharmony_ci		libogg
31b815c7f3Sopenharmony_ci		libogg_static
32b815c7f3Sopenharmony_ci	HINTS
33b815c7f3Sopenharmony_ci		${PC_OGG_LIBDIR}
34b815c7f3Sopenharmony_ci		${PC_OGG_LIBRARY_DIRS}
35b815c7f3Sopenharmony_ci		${OGG_ROOT}
36b815c7f3Sopenharmony_ci	)
37b815c7f3Sopenharmony_ci# Handle the QUIETLY and REQUIRED arguments and set OGG_FOUND
38b815c7f3Sopenharmony_ci# to TRUE if all listed variables are TRUE.
39b815c7f3Sopenharmony_ciinclude (FindPackageHandleStandardArgs)
40b815c7f3Sopenharmony_cifind_package_handle_standard_args (Ogg
41b815c7f3Sopenharmony_ci	REQUIRED_VARS
42b815c7f3Sopenharmony_ci		OGG_LIBRARY
43b815c7f3Sopenharmony_ci		OGG_INCLUDE_DIR
44b815c7f3Sopenharmony_ci	VERSION_VAR
45b815c7f3Sopenharmony_ci		OGG_VERSION
46b815c7f3Sopenharmony_ci	)
47b815c7f3Sopenharmony_ci
48b815c7f3Sopenharmony_ciif (OGG_FOUND)
49b815c7f3Sopenharmony_ci	set (OGG_LIBRARIES ${OGG_LIBRARY})
50b815c7f3Sopenharmony_ci	set (OGG_INCLUDE_DIRS ${OGG_INCLUDE_DIR})
51b815c7f3Sopenharmony_ci	
52b815c7f3Sopenharmony_ci	if(NOT TARGET Ogg::ogg)
53b815c7f3Sopenharmony_ci	add_library(Ogg::ogg UNKNOWN IMPORTED)
54b815c7f3Sopenharmony_ci		set_target_properties(Ogg::ogg PROPERTIES
55b815c7f3Sopenharmony_ci			INTERFACE_INCLUDE_DIRECTORIES "${OGG_INCLUDE_DIRS}"
56b815c7f3Sopenharmony_ci			IMPORTED_LOCATION "${OGG_LIBRARIES}"
57b815c7f3Sopenharmony_ci		)
58b815c7f3Sopenharmony_ci  endif ()
59b815c7f3Sopenharmony_ciendif ()
60b815c7f3Sopenharmony_ci
61b815c7f3Sopenharmony_cimark_as_advanced (OGG_INCLUDE_DIR OGG_LIBRARY)
62