| 1 |
#[=======================================================================[.rst: |
| 2 |
Findmpg123 |
| 3 |
------- |
| 4 |
|
| 5 |
Finds the mpg123 library. |
| 6 |
|
| 7 |
Imported Targets |
| 8 |
^^^^^^^^^^^^^^^^ |
| 9 |
|
| 10 |
This module provides the following imported targets, if found: |
| 11 |
|
| 12 |
``MPG123::libmpg123`` |
| 13 |
The mpg123 library |
| 14 |
|
| 15 |
Result Variables |
| 16 |
^^^^^^^^^^^^^^^^ |
| 17 |
|
| 18 |
This will define the following variables: |
| 19 |
|
| 20 |
``mpg123_FOUND`` |
| 21 |
True if the system has the mpg123 package. |
| 22 |
``mpg123_VERSION`` |
| 23 |
The version of mpg123 that was found on the system. |
| 24 |
|
| 25 |
Cache Variables |
| 26 |
^^^^^^^^^^^^^^^ |
| 27 |
|
| 28 |
The following cache variables may also be set: |
| 29 |
|
| 30 |
``mpg123_INCLUDE_DIR`` |
| 31 |
The directory containing ``mpg123.h``. |
| 32 |
``mpg123_LIBRARY`` |
| 33 |
The path to the mpg123 library. |
| 34 |
|
| 35 |
#]=======================================================================] |
| 36 |
|
| 37 |
if (mpg123_INCLUDE_DIR) |
| 38 |
# Already in cache, be silent |
| 39 |
set(mpg123_FIND_QUIETLY TRUE) |
| 40 |
endif () |
| 41 |
|
| 42 |
find_package (PkgConfig QUIET) |
| 43 |
pkg_check_modules(PC_MPG123 QUIET libmpg123>=1.25.10) |
| 44 |
|
| 45 |
find_path (mpg123_INCLUDE_DIR mpg123.h |
| 46 |
HINTS |
| 47 |
${PC_MPG123_INCLUDEDIR} |
| 48 |
${PC_MPG123_INCLUDE_DIRS} |
| 49 |
${mpg123_ROOT} |
| 50 |
) |
| 51 |
|
| 52 |
# MSVC built mpg123 may be named mpg123_static. |
| 53 |
# The provided project files name the library with the lib prefix. |
| 54 |
|
| 55 |
find_library (mpg123_LIBRARY |
| 56 |
NAMES |
| 57 |
mpg123 |
| 58 |
mpg123_static |
| 59 |
libmpg123 |
| 60 |
libmpg123_static |
| 61 |
HINTS |
| 62 |
${PC_MPG123_LIBDIR} |
| 63 |
${PC_MPG123_LIBRARY_DIRS} |
| 64 |
${mpg123_ROOT} |
| 65 |
) |
| 66 |
|
| 67 |
if (PC_MPG123_FOUND) |
| 68 |
set (mpg123_VERSION ${PC_MPG123_VERSION}) |
| 69 |
elseif (mpg123_INCLUDE_DIR) |
| 70 |
file (READ "${mpg123_INCLUDE_DIR}/mpg123.h" _mpg123_h) |
| 71 |
string (REGEX MATCH "[0-9]+.[0-9]+.[0-9]+" _mpg123_version_re "${_mpg123_h}") |
| 72 |
set (mpg123_VERSION "${_mpg123_version_re}") |
| 73 |
endif () |
| 74 |
|
| 75 |
# Handle the QUIETLY and REQUIRED arguments and set mpg123_FOUND |
| 76 |
# to TRUE if all listed variables are TRUE. |
| 77 |
include(FindPackageHandleStandardArgs) |
| 78 |
find_package_handle_standard_args (mpg123 |
| 79 |
REQUIRED_VARS |
| 80 |
mpg123_LIBRARY |
| 81 |
mpg123_INCLUDE_DIR |
| 82 |
VERSION_VAR |
| 83 |
mpg123_VERSION |
| 84 |
) |
| 85 |
|
| 86 |
if (mpg123_FOUND AND NOT TARGET MPG123::libmpg123) |
| 87 |
add_library (MPG123::libmpg123 UNKNOWN IMPORTED) |
| 88 |
set_target_properties (MPG123::libmpg123 |
| 89 |
PROPERTIES |
| 90 |
IMPORTED_LOCATION "${mpg123_LIBRARY}" |
| 91 |
INTERFACE_INCLUDE_DIRECTORIES "${mpg123_INCLUDE_DIR}" |
| 92 |
) |
| 93 |
endif () |
| 94 |
|
| 95 |
mark_as_advanced(mpg123_INCLUDE_DIR mpg123_LIBRARY) |