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