| 1 |
# - Find opus |
| 2 |
# Find the native opus includes and libraries |
| 3 |
# |
| 4 |
# OPUS_INCLUDE_DIRS - where to find opus.h, etc. |
| 5 |
# OPUS_LIBRARIES - List of libraries when using opus. |
| 6 |
# OPUS_FOUND - True if Opus found. |
| 7 |
|
| 8 |
if(OPUS_INCLUDE_DIR) |
| 9 |
# Already in cache, be silent |
| 10 |
set(OPUS_FIND_QUIETLY TRUE) |
| 11 |
endif() |
| 12 |
|
| 13 |
find_package(Ogg QUIET) |
| 14 |
|
| 15 |
find_package(PkgConfig QUIET) |
| 16 |
pkg_check_modules(PC_OPUS QUIET opus) |
| 17 |
|
| 18 |
set(OPUS_VERSION ${PC_OPUS_VERSION}) |
| 19 |
|
| 20 |
find_path(OPUS_INCLUDE_DIR opus/opus.h |
| 21 |
HINTS |
| 22 |
${PC_OPUS_INCLUDEDIR} |
| 23 |
${PC_OPUS_INCLUDE_DIRS} |
| 24 |
${OPUS_ROOT}) |
| 25 |
|
| 26 |
# MSVC built opus may be named opus_static. |
| 27 |
# The provided project files name the library with the lib prefix. |
| 28 |
|
| 29 |
find_library(OPUS_LIBRARY |
| 30 |
NAMES |
| 31 |
opus |
| 32 |
opus_static |
| 33 |
libopus |
| 34 |
libopus_static |
| 35 |
HINTS |
| 36 |
${PC_OPUS_LIBDIR} |
| 37 |
${PC_OPUS_LIBRARY_DIRS} |
| 38 |
${OPUS_ROOT}) |
| 39 |
|
| 40 |
# Handle the QUIETLY and REQUIRED arguments and set OPUS_FOUND |
| 41 |
# to TRUE if all listed variables are TRUE. |
| 42 |
include(FindPackageHandleStandardArgs) |
| 43 |
find_package_handle_standard_args(Opus |
| 44 |
REQUIRED_VARS |
| 45 |
OPUS_LIBRARY |
| 46 |
OPUS_INCLUDE_DIR |
| 47 |
Ogg_FOUND |
| 48 |
VERSION_VAR |
| 49 |
OPUS_VERSION) |
| 50 |
|
| 51 |
if(OPUS_FOUND) |
| 52 |
set(OPUS_LIBRARIES ${OPUS_LIBRARY}) |
| 53 |
set(OPUS_INCLUDE_DIRS ${OPUS_INCLUDE_DIR} ${Ogg_INCLUDE_DIRS}) |
| 54 |
|
| 55 |
if(NOT TARGET Opus::opus) |
| 56 |
add_library(Opus::opus UNKNOWN IMPORTED) |
| 57 |
set_target_properties(Opus::opus PROPERTIES |
| 58 |
INTERFACE_INCLUDE_DIRECTORIES "${OPUS_INCLUDE_DIR}" |
| 59 |
IMPORTED_LOCATION "${OPUS_LIBRARY}" |
| 60 |
INTERFACE_LINK_LIBRARIES Ogg::ogg) |
| 61 |
endif() |
| 62 |
endif() |
| 63 |
|
| 64 |
mark_as_advanced(OPUS_INCLUDE_DIR OPUS_LIBRARY) |