1b815c7f3Sopenharmony_ci# - Find lame
2b815c7f3Sopenharmony_ci# Find the native lame includes and libraries
3b815c7f3Sopenharmony_ci#
4b815c7f3Sopenharmony_ci#  MP3LAME_INCLUDE_DIRS - where to find lame.h, etc.
5b815c7f3Sopenharmony_ci#  MP3LAME_LIBRARIES    - List of libraries when using lame.
6b815c7f3Sopenharmony_ci#  MP3LAME_FOUND        - True if Lame found.
7b815c7f3Sopenharmony_ci
8b815c7f3Sopenharmony_ciif (MP3LAME_INCLUDE_DIR)
9b815c7f3Sopenharmony_ci    # Already in cache, be silent
10b815c7f3Sopenharmony_ci    set(MP3LAME_FIND_QUIETLY TRUE)
11b815c7f3Sopenharmony_ciendif ()
12b815c7f3Sopenharmony_ci
13b815c7f3Sopenharmony_cifind_path (MP3LAME_INCLUDE_DIR lame/lame.h
14b815c7f3Sopenharmony_ci	HINTS
15b815c7f3Sopenharmony_ci		${LAME_ROOT}
16b815c7f3Sopenharmony_ci	)
17b815c7f3Sopenharmony_ci
18b815c7f3Sopenharmony_ci# MSVC built lame may be named mp3lame_static.
19b815c7f3Sopenharmony_ci# The provided project files name the library with the lib prefix.
20b815c7f3Sopenharmony_ci
21b815c7f3Sopenharmony_cifind_library (MP3LAME_LIBRARY
22b815c7f3Sopenharmony_ci	NAMES
23b815c7f3Sopenharmony_ci		mp3lame
24b815c7f3Sopenharmony_ci		mp3lame_static
25b815c7f3Sopenharmony_ci		libmp3lame
26b815c7f3Sopenharmony_ci		libmp3lame_static
27b815c7f3Sopenharmony_ci		libmp3lame-static
28b815c7f3Sopenharmony_ci	HINTS
29b815c7f3Sopenharmony_ci		${MP3LAME_ROOT}
30b815c7f3Sopenharmony_ci	)
31b815c7f3Sopenharmony_ci
32b815c7f3Sopenharmony_cifind_library (MP3LAME_HIP_LIBRARY
33b815c7f3Sopenharmony_ci	NAMES
34b815c7f3Sopenharmony_ci		mpghip-static
35b815c7f3Sopenharmony_ci		libmpghip-static
36b815c7f3Sopenharmony_ci	HINTS
37b815c7f3Sopenharmony_ci		${MP3LAME_ROOT}
38b815c7f3Sopenharmony_ci	)
39b815c7f3Sopenharmony_ci
40b815c7f3Sopenharmony_ci# Handle the QUIETLY and REQUIRED arguments and set LAME_FOUND
41b815c7f3Sopenharmony_ci# to TRUE if all listed variables are TRUE.
42b815c7f3Sopenharmony_ciinclude(FindPackageHandleStandardArgs)
43b815c7f3Sopenharmony_cifind_package_handle_standard_args (mp3lame
44b815c7f3Sopenharmony_ci	REQUIRED_VARS
45b815c7f3Sopenharmony_ci		MP3LAME_LIBRARY
46b815c7f3Sopenharmony_ci		MP3LAME_INCLUDE_DIR
47b815c7f3Sopenharmony_ci	)
48b815c7f3Sopenharmony_ci
49b815c7f3Sopenharmony_ciif (MP3LAME_FOUND)
50b815c7f3Sopenharmony_ci	set (MP3LAME_LIBRARIES ${MP3LAME_LIBRARY} ${MP3LAME_HIP_LIBRARY})
51b815c7f3Sopenharmony_ci	set (MP3LAME_INCLUDE_DIRS ${MP3LAME_INCLUDE_DIR})
52b815c7f3Sopenharmony_ci
53b815c7f3Sopenharmony_ci	if (NOT TARGET mp3lame::mp3lame)
54b815c7f3Sopenharmony_ci		add_library (mp3lame::mp3lame UNKNOWN IMPORTED)
55b815c7f3Sopenharmony_ci		set_target_properties (mp3lame::mp3lame PROPERTIES
56b815c7f3Sopenharmony_ci			INTERFACE_INCLUDE_DIRECTORIES "${MP3LAME_INCLUDE_DIRS}"
57b815c7f3Sopenharmony_ci			IMPORTED_LOCATION "${MP3LAME_LIBRARY}"
58b815c7f3Sopenharmony_ci		)
59b815c7f3Sopenharmony_ci		if (MP3LAME_HIP_LIBRARY AND (NOT TARGET mp3lame::mpghip))
60b815c7f3Sopenharmony_ci			add_library (mp3lame::mpghip STATIC IMPORTED)
61b815c7f3Sopenharmony_ci			set_property (mp3lame::mpghip PROPERTY IMPORTED_LOCATION "${MP3LAME_HIP_LIBRARY}")
62b815c7f3Sopenharmony_ci			set_property (TARGET mp3lame::mp3lame PROPERTY INTERFACE_LINK_LIBRARIES "mp3lame::mpghip")
63b815c7f3Sopenharmony_ci		endif ()
64b815c7f3Sopenharmony_ci	endif ()
65b815c7f3Sopenharmony_ciendif ()
66b815c7f3Sopenharmony_ci
67b815c7f3Sopenharmony_cimark_as_advanced(MP3LAME_INCLUDE_DIR MP3LAME_LIBRARY MP3LAME_HIP_LIBRARY)
68