• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# - Find mpg123
2# Find the native mpg123 includes and libraries
3#
4#  MPG123_INCLUDE_DIRS - where to find mpg123.h, etc.
5#  MPG123_LIBRARIES    - List of libraries when using mpg123.
6#  MPG123_FOUND        - True if Mpg123 found.
7
8if (MPG123_INCLUDE_DIR)
9    # Already in cache, be silent
10    set(MPG123_FIND_QUIETLY TRUE)
11endif ()
12
13find_package (PkgConfig QUIET)
14pkg_check_modules(PC_MPG123 QUIET libmpg123>=1.25.10)
15
16set (MPG123_VERSION ${PC_MPG123_VERSION})
17
18find_path (MPG123_INCLUDE_DIR mpg123.h
19	HINTS
20		${PC_MPG123_INCLUDEDIR}
21		${PC_MPG123_INCLUDE_DIRS}
22		${MPG123_ROOT}
23	)
24
25# MSVC built mpg123 may be named mpg123_static.
26# The provided project files name the library with the lib prefix.
27
28find_library (MPG123_LIBRARY
29	NAMES
30		mpg123
31		mpg123_static
32		libmpg123
33		libmpg123_static
34	HINTS
35		${PC_MPG123_LIBDIR}
36		${PC_MPG123_LIBRARY_DIRS}
37		${MPG123_ROOT}
38	)
39
40# Handle the QUIETLY and REQUIRED arguments and set MPG123_FOUND
41# to TRUE if all listed variables are TRUE.
42include(FindPackageHandleStandardArgs)
43find_package_handle_standard_args (Mpg123
44	REQUIRED_VARS
45		MPG123_LIBRARY
46		MPG123_INCLUDE_DIR
47	VERSION_VAR
48		MPG123_VERSION
49	)
50
51if (MPG123_FOUND)
52	set (MPG123_LIBRARIES ${MPG123_LIBRARY})
53	set (MPG123_INCLUDE_DIRS ${MPG123_INCLUDE_DIR})
54
55	if (NOT TARGET MPG123::libmpg123)
56		add_library (MPG123::libmpg123 UNKNOWN IMPORTED)
57		set_target_properties (MPG123::libmpg123 PROPERTIES
58			INTERFACE_INCLUDE_DIRECTORIES "${MPG123_INCLUDE_DIRS}"
59			IMPORTED_LOCATION "${MPG123_LIBRARIES}"
60		)
61	endif ()
62endif ()
63
64mark_as_advanced(MPG123_INCLUDE_DIR MPG123_LIBRARY)
65